Factorial ProgramThe factorial of a number n is defined by the product of all the digits from 1 to n (including 1 and n). For example, Note:
The simplest way to find the factorial of a number is by using a loop. There are two ways to find factorial in PHP:
Logic:
Factorial in PHPFactorial of 4 using for loop is shown below. Example: Output: Factorial using Form in PHPBelow program shows a form through which you can calculate factorial of any number. Example: Output: Factorial using Recursion in PHPFactorial of 6 using recursion method is shown. Example: Output: Next TopicArmstrong Number |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India