code: def _factln(num):
      # type: (int) -> float
      
  
      if num < 20:
          log_factorial = log(factorial(num))
      else:
          log_factorial = num * log(num) - num + log(num * (1 + 4 * num * (
              1 + 2 * num))) / 6.0 + log(pi) / 2
  
      return log_factorial
docs: Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise.