(n)
| 1 | _FAC_TABLE = [1, 1] |
| 2 | def 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 | |
| 15 | def main(): |
no test coverage detected