fork download
  1. (defun factorial (n)
  2. (let ((n! 1))
  3. (loop :for i :from 2 :to n :do (setf n! (* n! i)))
  4. n!))
  5.  
  6. (defconstant long-max-value 9223372036854775807)
  7.  
  8. (loop :for n :from 9 :to 40
  9. :for n! := (factorial n)
  10. :do (format t "~2d! = ~20d~%" n n!)
  11. :while (< n! long-max-value))
  12.  
  13. (format t "~26d~%" long-max-value)
Success #stdin #stdout 0.01s 27116KB
stdin
Standard input is empty
stdout
 9! =               362880
10! =              3628800
11! =             39916800
12! =            479001600
13! =           6227020800
14! =          87178291200
15! =        1307674368000
16! =       20922789888000
17! =      355687428096000
18! =     6402373705728000
19! =   121645100408832000
20! =  2432902008176640000
21! = 51090942171709440000
       9223372036854775807