“Programa Python para progressão geométrica” Respostas de código

Programa Python para progressão geométrica

#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
Gr@Y_orphan_ViLL@in##

Progressão geométrica em Python

def geometric_progression(a1, n, q):
    print(a1)
    for i in range(1, n + 1):
        power = i - 1
        t = a1 * q ** power
        print(t)
Shiny Serval

Respostas semelhantes a “Programa Python para progressão geométrica”

Perguntas semelhantes a “Programa Python para progressão geométrica”

Mais respostas relacionadas para “Programa Python para progressão geométrica” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código