Last active
August 5, 2017 04:42
-
-
Save fkenjikamei/913121f7d69ae8191450957c6cbb121b to your computer and use it in GitHub Desktop.
Dada a série "S=1+2+9+4+25+6+49...", faá um programa que um dado número inteiro representando N a quantidade desejada de termos 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:")) | |
soma=0 | |
for x in range(1, n+1): | |
if x%2!=0: | |
print(x**2) | |
soma+=x**2 | |
else: | |
soma+=x | |
print(x) | |
print("Soma: ",soma) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment