Python Program to input N number and print sum of N geometric terms

 




# sum = a + ar + ar**2 + ar**3 + ..... + ar**n


n= int (input ('Enter no of terms'))

a= int (input ('Enter value for a '))

r= int (input ('Enter value for r'))

sum=a

for i in range (1,n+1):

    sum = sum + (a*r**i)

    print (a*r**i, sum)

print ('Sum of series = ',sum)

Comments

Some popular posts

Python Program that computes the net amount of a bank account based a transaction log from console input.