Fix typo and function call in maths module (#13515)

This commit is contained in:
iddu
2025-10-15 19:33:33 +05:30
committed by GitHub
parent 709c18ee9f
commit e731514bd5
2 changed files with 2 additions and 2 deletions

View File

@@ -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__":

View File

@@ -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