>
> In conventional imperative/procedural languages, as you pointed out,
> the algorithm used to calculate the factorial would be dependent on
> available compute resources. In order to select the appropriate
> algorithm one might select an arbitrary value (let's say 1000) and
> decide to use one algorithm or another. Or we might use a totally
> different function altogether.
>
> Is this also the case with Clojure? Being a newbie I have not fully
> understood how one would tackle such a problem.


You can use the traditional, precise algorithm when n is tractable, and use
Stirling's formula to approximate for large n:

n! ~ sqrt(2*pi*n)*(n/e)^n

This approach seems reasonable to me, assuming you really need to handle the
large values.

-Brendan

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to