From 8744c7dd727dab57fd28fd3b5c330d2f90b7e704 Mon Sep 17 00:00:00 2001 From: Shivang Arya Date: Fri, 23 Jan 2026 17:02:12 +0530 Subject: [PATCH 1/2] Fix incorrect doctest references in fibonacci functions --- maths/fibonacci.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/maths/fibonacci.py b/maths/fibonacci.py index 71ff479f9cc2..b0516037b22d 100644 --- a/maths/fibonacci.py +++ b/maths/fibonacci.py @@ -91,15 +91,15 @@ def fib_iterative(n: int) -> list[int]: def fib_recursive(n: int) -> list[int]: """ Calculates the first n (0-indexed) Fibonacci numbers using recursion - >>> fib_iterative(0) + >>> fib_recursive(0) [0] - >>> fib_iterative(1) + >>> fib_recursive(1) [0, 1] - >>> fib_iterative(5) + >>> fib_recursive(5) [0, 1, 1, 2, 3, 5] - >>> fib_iterative(10) + >>> fib_recursive(10) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] - >>> fib_iterative(-1) + >>> fib_recursive(-1) Traceback (most recent call last): ... ValueError: n is negative @@ -119,7 +119,7 @@ def fib_recursive_term(i: int) -> int: >>> fib_recursive_term(-1) Traceback (most recent call last): ... - Exception: n is negative + ValueError: n is negative """ if i < 0: raise ValueError("n is negative") @@ -135,15 +135,15 @@ def fib_recursive_term(i: int) -> int: def fib_recursive_cached(n: int) -> list[int]: """ Calculates the first n (0-indexed) Fibonacci numbers using recursion - >>> fib_iterative(0) + >>> fib_recursive_cached(0) [0] - >>> fib_iterative(1) + >>> fib_recursive_cached(1) [0, 1] - >>> fib_iterative(5) + >>> fib_recursive_cached(5) [0, 1, 1, 2, 3, 5] - >>> fib_iterative(10) + >>> fib_recursive_cached(10) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] - >>> fib_iterative(-1) + >>> fib_recursive_cached(-1) Traceback (most recent call last): ... ValueError: n is negative @@ -176,7 +176,7 @@ def fib_memoization(n: int) -> list[int]: [0, 1, 1, 2, 3, 5] >>> fib_memoization(10) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] - >>> fib_iterative(-1) + >>> fib_memoization(-1) Traceback (most recent call last): ... ValueError: n is negative @@ -329,4 +329,4 @@ def fib_matrix_np(n: int) -> int: time_func(fib_memoization, num) # 0.0100 ms time_func(fib_recursive_cached, num) # 0.0153 ms time_func(fib_recursive, num) # 257.0910 ms - time_func(fib_matrix_np, num) # 0.0000 ms + time_func(fib_matrix_np, num) # 0.0000 ms \ No newline at end of file From 87eaeb4378eb4e4c64cbd2bc2c482de413f4482f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 11:40:38 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/fibonacci.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/fibonacci.py b/maths/fibonacci.py index b0516037b22d..595233cf8446 100644 --- a/maths/fibonacci.py +++ b/maths/fibonacci.py @@ -329,4 +329,4 @@ def fib_matrix_np(n: int) -> int: time_func(fib_memoization, num) # 0.0100 ms time_func(fib_recursive_cached, num) # 0.0153 ms time_func(fib_recursive, num) # 257.0910 ms - time_func(fib_matrix_np, num) # 0.0000 ms \ No newline at end of file + time_func(fib_matrix_np, num) # 0.0000 ms