Factorial of an input number through sticky form in PHP using for loop or using recursive function



Factorial of an input number through sticky form in PHP using for loop or using recursive function

Factorial of an input number through sticky form in PHP using for loop or using recursive function

https://www.plus2net.com/php_tutorial/factorial.php
Factorial of a number is multiplication of all numbers from 1 to the number itself. This is mentioned as n!.
Factorial of 5 is 5 * 4 * 3 * 2 * , similarly factorial of any number we can define like this
n! = n * (n-1)!

First we will get the factorial of a number by using for loop.
We will start from 1 and increase upto the input number, inside the loop we will multiply the increment with the result to get the factorial of the number.
We can also use one sticky form asking user to input one number, using this number factorial can be calculated.

Using recursive function.
As factorial of a number is product of number and factorial of number minus one, we can use one recursive function to get all the factorials starting from the number till 1 and then get the product of the factorials.
#factorial #factorialofnumber #PHPFACTORIAL #numerfactorial