Respuesta :
Answer:
See explaination
Explanation:
The code
#function named sum that accepts a variable
#containing an integer value as its parameter
#returns the sum of the numbers from 1 to to the parameter
def sum(n):
if n == 0:
return 0
else:
#call the function recursively
return n + sum(n - 1)
#Test to find the sum()
#function with parameter 5.
print(sum(5))
A recursive function is simply a function that continues to execute itself until a condition is satisfied
The recursive function sum in Python, where comments are used to explain each line is as follows:
#This defines the sum function
def sum(n):
#The function returns n, when n is 1 or less
if n <= 1:
return n
#Otherwise, the sum is calculated recursively
else:
return n + sum(n - 1)
Read more about recursive functions at:
https://brainly.com/question/13657607