Factorial using recursion

Program to find the factorial using recursion :

ALGORITHM:
long int FACTORIAL(int n)
if(n==1)
return n
else
return n*FACTORIAL(n-1)

C SOURCE CODE:

#include<stdio.h>
#include<conio.h>
void main()
{
int num;
long int fact;
printf(“n Enter the number:”);
scanf(“%d”,&num);
fact=factorial(n);
printf(“n FACTORIAL OF %d is %ld”,num,fact);
getch();
}

 

Leave a Reply

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