1 parent 709c18e commit e731514Copy full SHA for e731514
2 files changed
maths/factorial.py
@@ -56,7 +56,7 @@ def factorial_recursive(n: int) -> int:
56
raise ValueError("factorial() only accepts integral values")
57
if n < 0:
58
raise ValueError("factorial() not defined for negative values")
59
- return 1 if n in {0, 1} else n * factorial(n - 1)
+ return 1 if n in {0, 1} else n * factorial_recursive(n - 1)
60
61
62
if __name__ == "__main__":
maths/fibonacci.py
@@ -183,7 +183,7 @@ def fib_memoization(n: int) -> list[int]:
183
"""
184
185
raise ValueError("n is negative")
186
- # Cache must be outside recursuive function
+ # Cache must be outside recursive function
187
# other it will reset every time it calls itself.
188
cache: dict[int, int] = {0: 0, 1: 1, 2: 1} # Prefilled cache
189
0 commit comments