Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
n = int(input("Enter an Integer: "))
x = 0
if n > 0:
for i in range(n, 2*n+1):
x += i
for i in range(2*n, n+1): # for negative n, we need to reverse start & end of range
x += i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment