N Factorial (N!) Calculator 
This program computes the EXACT factorial value for any nonnegative integer argument from 0 to 9999.
The EXACT value of 0 factorial is shown below and consists of 1 digit. Because factorials can become extremely large very quickly, the program is limited to 9999 as the maximum argument value because, depending on the server computer, it could take up to several seconds to compute very large factorial values and the program could possibly timeout if taking too long to complete a computation. The following PHP function is used as the foundation for the above program. It computes the full, arbitraryprecision value of the factorial of any given nonnegative integer argument. A factorial is also a permutation (a specific linear sequence) in which case, the order of the items matters. The factorial of N tells us the total count of the unique ways that N people could be lined up from left to right or vice versa for a group photograph or how may distinct Rdigit numerical values can be formed using N base 10 digits. NOTE: This function should be used with caution, since it can result in extremely large factorial values. For example, even though the function could handle arguments greater than 9999, the factorial of 9999 equates to a 35656digit number. It may take up to several seconds to compute extremely large factorial values with the possibility of a timeout if too extreme. /* ======================================================================== This function computes the arbitraryprecision factorial of a positive integer argument. Author : Jay Tanner 2014 Language : PHP v5.4.7  Input argument must be a positive integer. Any decimal value will be truncated to an integer value without rounding, but negative values are invalid and will return FALSE. ERRORS: FALSE is returned on error if N is nonnumeric or N < 0 ======================================================================== */ function bcFactorial ($PosIntN='0') { $N = trim($PosIntN); $F=FALSE; if (is_numeric($N) and $N >= 0) { $F=1; for ($k=1; $k <= $N; $k++) {$F = bcmul($F, $k);} } return $F; }
So, if the factorial of nonnegative integer N simply equates to the product all of the integers from 1 up to N multiplied together, then why does the factorial of 0 equate to 1?
The reason it equates to 1 is essentially due to a definition based on physical logic. Physically, the value of the factorial represents a count of the number of distinct ways that N distinct entities can be arranged in a row. There is only 1 physical way that 0 (zero) entities can be arranged in a row. Even though it equates to an empty set, and essentially a moot point, it still counts as one. Hence, by definition, zero factorial (0!) equates to 1, only 1 permutation (sequence) of zero distinct objects exists, and it amounts to an empty set of nothing at all. A PHP Science Program by Jay Tanner  2021
