Created
August 5, 2017 04:29
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)