We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 823876e commit 0a08da7Copy full SHA for 0a08da7
1 file changed
Fibonacci.py
@@ -0,0 +1,20 @@
1
+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
7
+ return sequence
8
+
9
+try:
10
+ n = int(input("Upto how many digits you want the Fibonacci sequence: "))
11
+ if n<=0:
12
+ print("Enter a natural number.")
13
+ if n==1:
14
+ print("Fibonacci series of 1 digit is [0]")
15
+ 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)}")
19
+except Exception as e:
20
+ print(f"ERROR: {e}")
0 commit comments