Created
January 18, 2017 11:45
-
-
Save diunko/cbac62d294429241eda78727f8b7cf55 to your computer and use it in GitHub Desktop.
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
import sys | |
def Sum(N): | |
S = 0 | |
k = 1 | |
while k <= N: | |
S = S + k | |
k = k + 1 | |
return S | |
def Sum2(N): | |
return N*(N+1)//2 | |
N, = [int(s) for s in sys.stdin.readline().strip().split()] | |
if N < 1: | |
r = -Sum(-N) + 1 | |
print (r) | |
else: | |
r = Sum(N) | |
print (r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment