Write a Python Program to Find Sum of Natural Numbers Using Recursion

Python Program to Find Sum of Natural Numbers Using Recursion

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Python Program to Find Sum of Natural Numbers Using Recursion
Python Program to Find Sum of Natural Numbers Using Recursion

Write a Python Program to Find Sum of Natural Numbers Using Recursion

PROGRAM: Python Program to Find Sum of Natural Numbers Using Recursion

/* Python Program to Find Sum of Natural Numbers Using Recursion */

# Python program to find the sum of natural using recursive function

def recur_sum(n):
if n <= 1:
return n
else:
return n + recur_sum(n-1)

# change this value for a different result
num = 16

if num < 0:
print(“Enter a positive number”)
else:
print(“The sum is”,recur_sum(num))

OUTPUT :-

The sum is 136

Leave a Reply

Your email address will not be published. Required fields are marked *