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
It should return:
But it returns
It always returns the last (n=n-1) term of the GP.