Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion maths/factorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion maths/fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down