Elle Joy Vasquez 2
Create a Python script that will display the next 5 numbers in the sequence where each number is the sum of the previous two.
TEXT FILE
8 3
4 5
6 2
Output
8 3 11 14 25 39 64
4 5 9 14 23 37 50
6 2 8 10 18 28 46
M = int(input("How many sequences do you want to display? Answer: "))
number = []
count = 0
for i in range(M):
number.append([1, 1])
number[i][0], number[i][1] = map(int, input("Enter two integer (separated by a space): ").split())
for i in range(M):
print("\n")
count = 0
while count < 7:
print(number[i][0], end=' ')
tmp = number[i][0] + number[i][1]
number[i][0] = number[i][1]
number[i][1] = tmp
count += 1
Comments
Leave a comment