Created
July 15, 2018 07:33
-
-
Save TomColBee/c88d5cd175ef1804c86695fa4b416193 to your computer and use it in GitHub Desktop.
Coderbyte Python Challenge: SimpleAdding
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
# Have the function SimpleAdding(num) add up all the numbers from 1 to num. | |
# For example: if the input is 4 then your program should return 10 because 1 + 2 + 3 + 4 = 10. | |
def SimpleAdding(num): | |
sum = 0 | |
for x in range(1,num+1): | |
sum = sum + x | |
return sum | |
print(SimpleAdding(input())) | |
# print SimpleAdding(raw_input()) | |
# Simpler solution: | |
# return sum(range(1, num + 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment