Write a program to create a recursive function to calculate the sum of numbers from 0 to 10.
A recursive function is a function that calls itself, again and again.
Expected Output:
55
Solution:
def addition(num): if num: # call same function by reducing number by 1 return num + addition(num - 1) else: return 0 res = addition(10) print(res)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer