Skip to content

Instantly share code, notes, and snippets.

@fkenjikamei
Created August 5, 2017 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fkenjikamei/633cb4ee8130f547c63589825fdbb790 to your computer and use it in GitHub Desktop.
Save fkenjikamei/633cb4ee8130f547c63589825fdbb790 to your computer and use it in GitHub Desktop.
Série 1. Dada a série "S=(1/3)+(2/6)+(3/9)+(4/12)+...", faça um programa que dado um número inteiro representado por N (quantidade de termos desejados da série), apresenta a soma de todos os termos até N
n=int(input("Digite um numero:"))
x = 1
serie=3
soma = 0
while x <= n:
valor = serie*x
print("serie: "+str(valor))
soma += x/valor
x+=1
print(soma)
@fkenjikamei
Copy link
Author

Outra possível solução:

n=int(input("Digite um numero:"))

s=1/3
qtd=1

while qtd < n:
s=s+1/3
qtd=qtd+1

print(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment