added 7-10

This commit is contained in:
2024-12-07 22:22:21 +02:00
parent 017145b529
commit 94318de22d
4 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
# 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