A Fibonacci Series in which the first two numbers are 0 and 1 and the next numbers is sum of the preceding ones. It is a mathematical series, in which a number is get from the sum the two numbers present before it.
Xn = Xn-1 + Xn-2
# Program for Fibonacci series.
# Series : 0, 1, 1, 2, 3, 5, 8, 13, ..................
n = eval(input("Enter Number:"))
sum = 0
a = 0
b = 1
i = 1
while i < n :
if i == 1 :
print(0,end=" ")
elif i == 2 :
print(1,end=" ")
else :
sum = a+b
a = b
b = sum
print(sum,end=" ")
i += 1
print()
Comments