added 7-10
This commit is contained in:
16
basic programming/2nd task/9.py
Normal file
16
basic programming/2nd task/9.py
Normal 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
|
||||
Reference in New Issue
Block a user