C Program to calculate factorial using recursion

Simple C program to calculate factorial of a number using recursion: Factorial of a number is given by multiplication of 1 to n. For example if number is 5 then factorial of 5 = multiplication of 1 to n numbers = 1*2*3*4*5 = 120. Factorial of 0 is given by 1.
/* C program to calculate factorial using recursion */
#include<stdio.h>
int Factorial(int n)
{
 if(n==0)
 return 1;
 return n*Factorial(n-1);
}
int main()
{
 int n;
 printf("Enter a number: ");
 scanf("%d",&n);
 printf("Factorial of %d = %d",n,Factorial(n));
 return 0;
}
/* End of program */

Popular posts from this blog