Computer Science, asked by adarshak8924, 9 months ago

Write a program using recursion to calculate the sum of first n natural nos

Answers

Answered by rishabhagrawal0
0

Answer:

Explanation:

# Python code to find sum  

# of natural numbers upto  

# n using recursion  

# Returns sum of first  

# n natural numbers  

def recurSum(n):  

if n <= 1:  

 return n  

return n + recurSum(n - 1)  

# Driver code  

n = 5

print(recurSum(n))  

Similar questions