First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

Write a Python program to get the Fibonacci series between 0 to 50.

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

2 Answers

more_vert
a,b=0,1

while b<50:
    print(b)
    a,b= b,a+b
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
more_vert
n=int(input("Enter the length of fibonacci series : "))

a=0
b=1
print("Series : ")
for i in range(n):
    if n<0:
        print("Invalid input")
    
    elif n==0:
        print(0)
    
    elif n==1:
        print(1)

    else:
        c=a+b
        a=b
        b=c
        print(b)
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...