factorial
Computes and returns the factorial for a given number .
$$n! = n \times (n-1) \times \cdots \times 1$$
NOTE: is the largest factorial GameMaker can precisely compute. It may appear to produce correct results up to but computations using them are dubious and precision decreases as they get larger.
- factorial(number)
- Returns the factorial of a given number.
COPY/// @func factorial(number)
///
/// @desc Returns the factorial of a given number. Numbers
/// larger than 18 produce inaccruate results due to
/// floating-point precision limitations.
///
/// @param {real} number non-negative integer
///
/// @return {real} factorial of given number
///
/// GMLscripts.com/license
function factorial(number)
{
if (number <= 1) return 1;
return number * factorial(number - 1);
}
Contributors: xot
GitHub: View · Commits · Blame · Raw