Hi Folks,
I was looking directly for some large factorial calculator in Octave and did not
find any, hence took a while to find a solution. It could also be my fault, but
for users not initiated in it must be beneficial to have a direct solution which
is documented somewhere. Matlab does not have such a function `lfactorial`, but
R does. Here is another one and Octave would own it too.
After looking at Octave's `factorial.m` that was straightforward to implement.
Someone probably can find a place (e.g. in specfun pkg in Octave-Forge) for this
feature.
Source is attached to spread it around...
I excluded rounding, because it approximates on natural log scale. So it would
return float or double in case of typed usage.
Could you appreciate it, I would finish it up by documenting and complete the
whole source with the administration parts of it.
Cheers,
mAkos
## lfactorial.m
function ans = lfactorial (n)
if (nargin != 1)
print_usage ();
elseif (any (n(:) < 0 | n(:) != round (n(:))))
error ("factorial: N must all be nonnegative integers");
endif
ans = lgamma (n+1);
endfunction
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev