PYTHON- write a program that accepts a param (num) that will determine how many numbers will be in the output. every number after the first is the product of the prev 2 numbers, we will always start with [5,2] . return output (list)
example. the user will insert 6 as the num. we start with [5,2] and the output will be [5,2,10,20,200,4000]
num = int(input("How many terms? "))
n1, n2 = 5, 2
count = 0
print("Output:")
while count < num:
print(n1)
nth = n1 * n2
# update values
n1 = n2
n2 = nth
count += 1
Explanation:
In thsi program n1 is multiplied by n2 and stored in nth and then n2 value is stored in n1, nth in n2
Hope you like the answer.
Get Answers For Free
Most questions answered within 1 hours.