mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Fix typo and function call in maths module (#13515)
This commit is contained in:
@@ -56,7 +56,7 @@ def factorial_recursive(n: int) -> int:
|
||||
raise ValueError("factorial() only accepts integral values")
|
||||
if n < 0:
|
||||
raise ValueError("factorial() not defined for negative values")
|
||||
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)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -183,7 +183,7 @@ def fib_memoization(n: int) -> list[int]:
|
||||
"""
|
||||
if n < 0:
|
||||
raise ValueError("n is negative")
|
||||
# Cache must be outside recursuive function
|
||||
# Cache must be outside recursive function
|
||||
# other it will reset every time it calls itself.
|
||||
cache: dict[int, int] = {0: 0, 1: 1, 2: 1} # Prefilled cache
|
||||
|
||||
|
||||
Reference in New Issue
Block a user