1#Python program to generate Fibonacci series until 'n' value
2n = int(input("Enter the value of 'n': "))
3a = 0
4b = 1
5sum = 0
6count = 1
7print("Fibonacci Series: ", end = " ")
8while(count <= n):
9 print(sum, end = " ")
10 count += 1
11 a = b
12 b = sum
13 sum = a + b
14
1# Python program to display the Fibonacci sequence
2
3def recur_fibo(n):
4 if n <= 1:
5 return n
6 else:
7 return(recur_fibo(n-1) + recur_fibo(n-2))
8
9nterms = 10
10
11# check if the number of terms is valid
12if nterms <= 0:
13 print("Plese enter a positive integer")
14else:
15 print("Fibonacci sequence:")
16 for i in range(nterms):
17 print(recur_fibo(i))
18
1num = 1
2num1 = 0
3num2 = 1
4import time
5for i in range(0, 10):
6 print(num)
7 num = num1 + num2
8 num1 = num2
9 num2 = num
10 time.sleep(1)
11
1#Learnprogramo
2Number = int(input("How many terms? "))
3# first two terms
4First_Value, Second_Value = 0, 1
5i = 0
6if Number <= 0:
7print("Please enter a positive integer")
8elif Number == 1:
9print("Fibonacci sequence upto",Number,":")
10print(First_Value)
11else:
12print("Fibonacci sequence:")
13while i < Number:
14print(First_Value)
15Next = First_Value + Second_Value
16# update values
17First_Value = Second_Value
18Second_Value = Next
19i += 1