23 Feb Friday 17:00 Python Practice 21.02.19.
Use the recursion we have learn in the class, please try to create a function to recursively calculate the total of 1 + 2 + …. (n-2) + (n-1) + n
# please write you program below
total(int(input('Please enter a number:')))
All recursive algorithms must obey three important laws:
A recursive algorithm must have a base case.
A recursive algorithm must change its state and move toward the base case.
A recursive algorithm must call itself, recursively.
if len(numList) == 1:
return numList + listsum(numList[1:])