Skip to content
Closed
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
5 changes: 3 additions & 2 deletions maths/fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
...
ValueError: n is negative
"""
if n < 0:
raise ValueError("n is negative")
def fib_iterative(n: int) -> list[int]:
_validate_int_non_negative("n", n)

Check failure on line 57 in maths/fibonacci.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

maths/fibonacci.py:57:5: F821 Undefined name `_validate_int_non_negative`

a, b = 0, 1
yield a
for _ in range(n):
Expand All @@ -62,7 +63,7 @@
a, b = b, a + b


def fib_iterative(n: int) -> list[int]:

Check failure on line 66 in maths/fibonacci.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F811)

maths/fibonacci.py:66:5: F811 Redefinition of unused `fib_iterative` from line 56
"""
Calculates the first n (0-indexed) Fibonacci numbers using iteration
>>> fib_iterative(0)
Expand Down
Loading