This is what I've got and I'm not sure why it's not working:
def sum(n):
if n > 0:
print(n)
return sum(n) + sum(n-1)
else:
print("done doodly")
number = int(input(": "))
sum(number)
For example if the user inputs 5
, I want the program to calculate the sum of 5+4+3+2+1. What am I doing wrong?
For the non-recursive version of this question, see Sum of the integers from 1 to n