Skip to content

Instantly share code, notes, and snippets.

@aahnik
Last active September 14, 2020 12:20
Show Gist options
  • Save aahnik/e796478ee3d89412a817ec678338ab62 to your computer and use it in GitHub Desktop.
Save aahnik/e796478ee3d89412a817ec678338ab62 to your computer and use it in GitHub Desktop.
sum of n natural numbers for loop python
def sum(n):
s = 0
for i in range(1,n+1):
s += n
print(s)
sum(10)# would print 55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment