Created
November 9, 2016 13:30
-
-
Save nicholaskajoh/1cf2e209f7a04e45d3d0a40cff5be9c1 to your computer and use it in GitHub Desktop.
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
# Get the sum of a list of numbers without using a for loop | |
def add(arr, s = 0): | |
s += arr[0] | |
if len(arr) > 1: | |
s += add(arr[1:]) | |
return s | |
print("Sum", add([1, 2, 3, 4, 5])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment