faster factorial



>>>>> "Richard" == Richard Fateman <fateman at cs.berkeley.edu> writes:

    Richard> For GCL, this program is faster than the much longer one used in Maxima
    Richard> (defined in ASUM.lisp.).

    Richard> Almost  3X faster computing 20000!  .


    Richard> (defun k (n m) ;; (k n 1) is n!
    Richard>   (declare (fixnum n m))
    Richard>   (if (<= n m) n
    Richard>     (* (k n (* 2 m))
    Richard>        (k (- n m)(* 2 m)))))

Nice.  With CMUCL, after compiling K, I get:

(%i48) (20000!, 0);
Evaluation took 1.95 seconds (2.25 elapsed) using 15.045 MB.
(%o48) 				       0
(%i49) (?k(20000,1),0);
Evaluation took 0.50 seconds (0.52 elapsed) using 926.805 KB.

for a speed up of about 4X and 16x less consing.

Perhaps we should consider using this in Maxima instead of the current
one, at least CMUCL and SBCL (which probably has similar speed up).

Ray