Files
2024-12-07 22:22:21 +02:00

17 lines
539 B
Python

# Q9
# Initialize the variables for the first two numbers in the Fibonacci sequence
a = 0 # The first number
b = 1 # The second number
# Print the first two numbers
print(a, end=" ")
print(b, end=" ")
# Calculate and print the next numbers in the Fibonacci sequence
for _ in range(8): # We have already printed the first two numbers, so we need 8 more
c = a + b # The next number is the sum of the previous two numbers
print(c, end=" ")
a = b # Move the values: a gets the value of b
b = c # b gets the value of c