Skip to content

Instantly share code, notes, and snippets.

@AndreUltrasi
Created November 27, 2016 01:44
Show Gist options
  • Save AndreUltrasi/0e0850434f199faa78bc409a6a9b9237 to your computer and use it in GitHub Desktop.
Save AndreUltrasi/0e0850434f199faa78bc409a6a9b9237 to your computer and use it in GitHub Desktop.
Série 1+2+3+4...=(m*(m+1))/2 em python
print("k1 = 1")
print("k1+ k2 +...+ m = (m*(m+1))/2")
k = 1
m=int(input("m = "))
tmp = k
print("k = ",k)
print("sum = ", tmp)
while k < m:
k+=1
tmp+=k
print("k = ",k)
print("sum = ", tmp)
print("(m*(m+1))/2 = ",(m*(m+1))/2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment