Last active
September 14, 2020 12:20
-
-
Save aahnik/e796478ee3d89412a817ec678338ab62 to your computer and use it in GitHub Desktop.
sum of n natural numbers for loop python
This file contains 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
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