79656357

Date: 2025-06-06 19:03:47
Score: 0.5
Natty:
Report link

If you want a really simple way to print a certain number of items in the fibonacci sequence you can do this:

num = input("How many numbers of the fibonacci sequence would you like to print?\n\n")
numbers = int(num)

a = 0
b = 1
print(a)
print(b)
for i in range(numbers):
    c = a + b
    print(c)
    a = b
    b = c

Since the rule of the fibonacci sequence is to have each item be the sum of the previous two items, you can create two variables, add them then set the value of the variables a and b to the new values of b and c and continue the loop.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: OkCoder