We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Ballyhoo


Posted By

darkphotn on 01/13/08


Tagged

number Large LISP factorial


Versions (?)


Large Factorials in LISP


Published in: Lisp 


Large factorials are easy to do in LISP, although a number above (2000!) may crash it. I designed this because of an online post from a mathematician talking about the number 1000! . Code like this is difficult to write in C-like languages, but a snap in LISP, as the following code demonstrates.


  1. (defun factorial(x)
  2. (cond ((zerop x) 1)
  3. ('T (* x (factorial (1- x)))) ))
  4.  
  5. (factorial 1000)

Report this snippet 

You need to login to post a comment.