The factorial of a number n is defined by the product of all the digits from 1 to n (including 1 and n). Here we write program, how to print factorial of any number in php.
For Example:
5! = 5*4*3*2*1 = 120
Factorial of 0 is always 1
#include
#include
void main()
{
int n,i,fact=1;
clrscr();
printf(“Enter any no: ”);
scanf(“%d”,&n);
for(i=n;i>=1;i--)
{
fact=fact*i;
}
printf(“Factorial=%d”,fact);
getch();
}
************************* output: Enter a no: 5 Factorial=120*************************