# Factorial in ruby

**URL:** <https://www.ruby-forum.com/t/factorial-in-ruby/92161>\
**Category:** Ruby\
**Created:** [April 16, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/factorial-in-ruby/92161 "2007-04-16T19:38:17Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [April 21, 2007, 3:43am UTC](https://www.ruby-forum.com/t/factorial-in-ruby/92161/21 "2007-04-21T03:43:25Z")

</div>

Gary Thomas wrote:

> Except for calculating binomial coefficients for probability calculations or  
> closely related things. I can’t think of any reason to calculate large  
> factorials. In the case of binomial coefficients it is better to cancel out  
> some of the factors and avoid calculating the huge factorials. If the  
> numbers are large, the use of approximations is almost certainly a better  
> approach

A rule of thumb I was taught in the days when compute power was  
expensive was that any factorial over 10! should be done using  
Stirling’s approximation. I think that’s a reasonable strategy even  
today.

–  
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)  
[http://borasky-research.net/](http://borasky-research.net/)

If God had meant for carrots to be eaten cooked, He would have given  
rabbits fire.

[Previous page](https://www.ruby-forum.com/t/factorial-in-ruby/92161.md?page=1)
