Hi!
I'm new at python and I don't get the while statement. I'm trying to make a simple function that returns each term of a geometric progression 'til 'n'.
def gp(a1,r,n):
while not n == 0:
n = n - 1
an = a1 * (r ** n)
return an
For gp(3,3,3)
It should return:
27
9
3
But it returns
27
It always returns the last (n=n-1) term of the GP.