Factorial of Number using Recursive function in C language

Factorial of Number using Recursion


#include<stdio.h>
int GetFactorial(int number);
 main()
{
 int number,factorial;
 printf(“Enter a number for factorialn”);
 scanf(“%d”,&number);
 factorial=GetFactorial(number);
 printf(“%d!=%dn”,number,factorial);

}
int GetFactorial(int number)
{
 if(number>0)
{
 return number*GetFactorial(number-1);

}
 else
{
 return 1;

}

}

Output:-

 Enter a number for factorial
4!= 24

Leave a Comment

error: Content is protected !!