From 49c7836556ccd6510e47dbb6721be680a67b065f Mon Sep 17 00:00:00 2001 From: Nikhil-Kumar-Wui Date: Sun, 23 Mar 2025 00:22:11 +0530 Subject: [PATCH] Fixed two issues in fixme.py: changed elif n==2 to n==1 for correct Fibonacci values and placed return b outside the loop but inside the function. --- fixme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fixme.py b/fixme.py index bed76dd..a1313db 100644 --- a/fixme.py +++ b/fixme.py @@ -1,13 +1,13 @@ def fibonacci_iterative(n): if n <= 0: return 0 - elif n == 2: #Fix me + elif n == 1: #Fix me return 1 a, b = 0, 1 for _ in range(2, n+1): a, b = b, a + b - return b # Fix me. + return b # Fix me. n = 10 print(f"The {n}th Fibonacci number is: {fibonacci_iterative(n)}") \ No newline at end of file