[PLUG-TALK] Autodialer numerical math puzzle

Russell Senior seniorr at aracnet.com
Wed Jun 14 11:00:20 UTC 2006


>>>>> "Russell" == Russell Senior <seniorr at aracnet.com> writes:

Russell> I wasn't willing to waste enough time to confirm I got the
Russell> right number.  I just trust that the underlying
Russell> implementation of log and exp are good enough.

Heh.  Okay, so I *was* willing to waste enough time to confirm I got
the right number (grrr!).  I also ran a computation using bignums:

  (defun factorial (n)
    (loop for i from 1 upto n
          for j = 1 then (* j i)
          finally (return j)))

and then wrapped it in something that would print to a file:

  (with-open-file (out "/tmp/factorial-factorial-9.txt"
                   :direction :output
                   :if-exists :supersede)
    (print (factorial 362880) out))

Substantially slower, but CMUCL and SBCL both generated results, see:

  <http://www.aracnet.com/~seniorr/factorial-factorial-9.txt>

(use wget, it made my mozilla blow up).


-- 
Russell Senior         ``I have nine fingers; you have ten.''
seniorr at aracnet.com



More information about the PLUG-talk mailing list