Guest User

Untitled

a guest
Dec 8th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.55 KB | None | 0 0
  1. ;;; with default optimizations
  2. (defun factorial (n)
  3.   (cond ((= n 0) 1)
  4.     (t (* n (factorial (- n 1))))))
  5.  
  6.  
  7. ;;; poor, c conversion, :)
  8. #+:clisp
  9. (format t "~S~&" (factorial 6000))
  10.  
  11. ;;; better, :)
  12. #+:ecl
  13. (format t "~S~&" (factorial 12000))
  14.  
  15. ;;; this is already optimized by default
  16. #+:cmu
  17. (format t "~S~&" (factorial 100000))
  18.  
  19. ;;; the numbers are random, that means i didn't try to find a limit,
  20. ;;; just stop before 'stack overflow' for clisp and ecl, first hit
  21. ;;; from cmucl
  22. ;;;
  23. ;;; usage, just (load "fact.lisp") in the interpretor.
  24. ;;;
Add Comment
Please, Sign In to add comment