Program to print the Fibonacci sequence up to a given number using a while loop in Python:
# While loop in Python - Fibonacci sequence
num = int(input("Enter a number: "))
a, b = 0, 1
while a <= num:
print(a)
a, b = b, a + b
# While loop in Python - Fibonacci sequence
num = int(input("Enter a number: "))
a, b = 0, 1
while a <= num:
print(a)
a, b = b, a + b
Comments
Post a Comment