PHP | Factorial of a number
We already know how to get the factorial of a number in other languages. Let’s see how this is done in PHP using both recursive and non-recursive ways.
Input : 5 Output : 120 Input : 10 Output : 3628800
Method 1: Iterative way
In this method, we simply used the for loop to iterate over the sequence of numbers to get the factorial.
Method 2: Use of recursion
In this method we are calling the same method to get the sequence of the factorial.