Python Program to Find Sum of Natural Numbers using Recursion
Write Python Program to Find Sum of Natural Numbers using Recursion
# Write Python Program to Find Sum of Natural Numbers using Recursion def sum_number(n): result = 0 if n == 1: result = 1 else: result = n + sum_number(n - 1) return result n = 10 Sum = sum_number(n) print(f'Sum of first {n} numbers : {Sum}')
Output:
Sum of first 10 numbers : 55