📅  最后修改于: 2022-03-11 14:46:08.442000             🧑  作者: Mango
#sum of terms in geometric proggression in python
x=int(input('Enter the value of x :'))
n=int(input('Enter the value of n :'))
total=1
for i in range(1,n+1):
s=x**i
total+=s
print('term',i,'is',s)
print('The sum of the series 1+x+x2+x3+....+xn=',total)
#Output
Enter the value of x :2
Enter the value of n :4
term 1 is 2
term 2 is 4
term 3 is 8
term 4 is 16
The sum of the series 1+x+x2+x3+....+xn= 31