MCPcopy Create free account
hub / github.com/ActiveState/code / factorial

Function factorial

recipes/Python/577241_Faster_Factorial/recipe-577241.py:2–12  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

1_FAC_TABLE = [1, 1]
2def factorial(n):
3 if n < len(_FAC_TABLE):
4 return _FAC_TABLE[n]
5
6 last = len(_FAC_TABLE) - 1
7 total = _FAC_TABLE[last]
8 for i in range(last + 1, n + 1):
9 total *= i
10 _FAC_TABLE.append(total)
11
12 return total
13
14
15def main():

Callers 10

maclaurin_cos_pow2Function · 0.50
maclaurin_cosFunction · 0.50
maclaurin_sinFunction · 0.50
ShapleySubFunction · 0.50
recipe-578115.pyFile · 0.50
maclaurin_expenantialFunction · 0.50
maclaurin_sinhFunction · 0.50
maclaurin_binomialFunction · 0.50
maclaurin_coshFunction · 0.50
maclaurin_cos_2xFunction · 0.50

Calls 2

rangeFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected