Example: Sum of Natural Numbers
# Program to find the sum of natural numbers upto n using recursion
calculate_sum()
Output
> calculate_sum(7) [1] 28
Here, we ask the user for a number. The number entered by the user is passed to calculate_sum()
recursive function which computes the sum up to that number.