MediumPython program to print fibonacci series - Python Assignment and Solutions - Medium
Sitemap

Python program to print fibonacci series

#Python program to print Fibonacci series 1 2 3 5 8 13 21 ...100

'''
Understanding problem
Next digit of series is sum of previous two digits
1,2,3(2+1),5(2+3)...

'''
#Python Code
a =1 #First Digit
b =2 #Second Digit
print(a, end=" ")#For space after digit
print(b,end =" ")
c=a+b #Third Digit
#learnskill-online.com
while c<=100: #Will enter in loop only if digit to be print is less than 100
print(c,end=" ")
a=b #shift of digits
b=c
#learnskill-online.com
c=a+b#Next digit
#Final output
#1 2 3 5 8 13 21 34 55 89

--

--