|
A geometric progression is a sequence of numbers in which each value (after the first) is obtained by multiplying the previous value in the sequence by a fixed value called the common ratio. For example the sequence 3, 12, 48, 192, ... is a geometric progression in which the common ratio is 4.
Given the positive integer ratio greater than 1, and the non-negative integer n , create a list consisting of the geometric progression of numbers between (and including) 1 and n with a common ratio of ratio . For example, if ratio is 2 and n is 8, the list would be [1, 2, 4, 8] .
Associate the list with the variable geom_prog .
I am trying this problem using a For loop but I think my types might be mixed around I am not 100% sure on writing to a list but here is my code but it is incorrect.
geom_prog = 0 for i in range(1,n+1): geom_prog += i * ratio
|