Factorial:
-factorial of number is the multiplication of every integer number between 1 and that number.
Example-
factorial of 3 is 6(1*2*3)
factorial of 5 is 120(1*2*3*4*5)
Recursion:
-Function call itself is called as Recursion.
-We can also use the recursion concept at the place of the loop.
program-
#include < stdio.h>
int Factorial(int n)
{
if(n==1)
return 1;
else
return n*Factorial(n-1);
}
int main()
{
int n,ans;
printf("Enter Numbern");
scanf("%d",&n);
ans=Factorial(n);
printf("Factorial is %d",ans);
}
Enter Number
5
Factorial is 120