factorial | ![]() |
Returns the factorial for num, also known as n!.
It uses iteration and returns a real number if the result is higher than the maximum integer number *MAX-INT*
It is optimized to work with large numbers which are not computable without tricks.
The implementation uses a fast method for arguments >= 12 (Stirling's ln(x!)), which is not 100% accurate, just a fast approximation. So there will be significant accuracy errors for arguments >15
(factorial 4) => 24 = (* 1 2 3 4) (factorial 10) => 3628800 (factorial 15) => 1307674368000.0 (factorial 16) != 20922789888000.0 ;*** ERROR: => 2.09228e+013 ; * Tolerance: 0.1 ; * Numeric diff: 0.285156 (factorial 17) != 355687428096000.0 ;*** ERROR: => 3.55687e+014 ; * Tolerance: 0.1 ; * Numeric diff: 4.0
num: Any positive integer number.
An integer or real number.
None.
(std-require 'COMBINATIONS)
Defined in COMBINATIONS