Python Program to Find Sum of N Natural Numbers Using Recursion

Python Program to Find Sum of N Natural Numbers Using Recursion

Example

def Sum(N):
    if N==1:
        return(1)
    return (N+Sum(N-1))


n = int(input('Enter Input: '))
#n=5
addition = Sum(n)
print("Sum Of {} Natural Number Is: {}".format(n,addition))

Output:

Enter Input: 5
Sum Of 5 Natural Nmber Is: 15

Leave a comment