specfun_factorial — The factorial function
f = specfun_factorial ( n )
a matrix of floating point integers, must be positive
a matrix of floating point integers
Returns the factorial of n, that is, the product of all integers 1 * 2 * ... * n.
This function overflows as soon as n>170.
Our tests indicate that this function is exact for n lower or equal to 16. For n>16, the relative error can be as large as 200*%eps.
// Make a table of factorial n = (0:30)'; [n specfun_factorial(n)] // See that we must round the gamma function n = 12; specfun_factorial(n) gamma(n+1) // See the limits of factorial: f(171)=%inf specfun_factorial(170) // 7.257415615307998967e306 specfun_factorial(171) // %inf // Plot the function on all its range. scf(); plot ( 1:170 , specfun_factorial , "b-o" ) h = gcf(); h.children.log_flags="nln";