We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 75759a2 commit 430c8ebCopy full SHA for 430c8eb
1 file changed
Fibonacci.py
@@ -1,9 +1,8 @@
1
-def Fibonacci(n):
+def fibonacci(n):
2
sequence = [0,1]
3
- i = 0
4
- while i<(n-2):
5
- sequence.append(sequence[i] + sequence [i+1])
6
- i += 1
+
+ for _ in range(n-2):
+ sequence.append(sequence[-2] + sequence [-1])
7
return sequence
8
9
try:
@@ -15,6 +14,6 @@ def Fibonacci(n):
15
14
if n==2:
16
print("Fibonacci series of 2 digit is [0,1]")
17
if n>2:
18
- print(f"Fibonacci series of {n} digit is:\n{Fibonacci(n)}")
+ print(f"Fibonacci series of {n} digit is:\n{fibonacci(n)}")
19
except Exception as e:
20
print(f"ERROR: {e}")
0 commit comments