Skip to content

Instantly share code, notes, and snippets.

@e-parkinson
Last active August 29, 2015 14:28
Show Gist options
  • Select an option

  • Save e-parkinson/21ac315f9590cc3aab0b to your computer and use it in GitHub Desktop.

Select an option

Save e-parkinson/21ac315f9590cc3aab0b to your computer and use it in GitHub Desktop.
Snippet: find sum of natural numbers to n inclusive using iteration
n = int(input())
running_total = 0
for i in range(0,n+1):
running_total += i
print(running_total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment