def factorial(N):
"""Compute the factorial of N.
If N <= 16, use a fast lookup table; otherwise use scipy.special.factorial
"""
if N < len(FACTORIALS):
return FACTORIALS[N]
elif scipy_special is None:
raise ValueError("need scipy for computing larger factorials")
else:
return int(scipy_special.factorial(N))
评论列表
文章目录