## Write a program find Factorial of a number

Here we are writing a program of print the factorial of a number, factorial means 1 to n multiply them where n is defined by the product of all the digits from 1 to n.

1. Factorial is denoted by n!.
2. Factorial is calculated only for positive integers(9) not for nagative integers(-2).
3. Do you know Factorial of 0 is always 1.
4. The best and simle way to calculate the factorial of a number is by using a loop or recursive method.

Here we are calculating factorial of number using two method one is using while and second using for loop.

## PHP Program to find factorial of number using while loop:

```<?php
\$num = 5;
\$factorial = 1;
while(\$num>=1)
{
\$factorial = \$factorial*\$num;
\$num--;
}
echo "Factorial of \$num is \$factorial";
?>
```

## PHP Program to find factorial of number using for loop:

```<?php
\$num = 5;
\$factorial = 1;
for (\$i=\$num; \$i>=1; \$i--)
{
\$factorial = \$factorial * \$i;
}
echo "Factorial of \$num is \$factorial";
?>
```

## PHP program to Print factorial of a number using HTML Form

```<form method="post">
<input type="text" name="number" placeholder="Enter number" />
<input type="submit" value="Submit" />
</form>

<?php
if(isset(\$_POST['number']))
{
\$num = \$_POST['number'];
\$factorial = 1;
for (\$i=\$num; \$i>=1; \$i--)
{
\$factorial = \$factorial * \$i;
}
echo "Factorial of \$num is \$factorial";
}
?>
```

Keywords:
PHP program to Print factorial of a number, find factorial of a number, calculate factorial of a number, Program for factorial of a number, Factorial Calculator n!, factorial in php, factorial of a number in php, factorial of number using for loop, factorial of number using while loop, factorial calculator, factorial list

My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.

25/09/2022

05/09/2022

13/07/2022

13/07/2022

31/05/2022