C Program for finding the sum of first n natural numbers using Recursion
#include<stdio.h>
#include<conio.h>
int sum(int
n);
void main()
{
int num;
clrscr();
printf("Enter the nth Number for find sum
of first n natural numbers\n");
scanf("%d",&num);
printf("\nThe Sum of first %d natural
numbers is %d\n",num,sum(num));
getche();
}
int sum(int
n)
{
if(n==1)
return 1;
else
return(n+sum(n-1));
}
OUTPUT
------------------------------------------------------------------------------------------------------------
You can also visit:-