[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: performance and style advice requested

Warren Brown

9/16/2003 9:16:00 PM

Hal,

> Unfortunately, I can't remember exactly how
> it works.
>
> There are formulae that involve (n-k)!,
> perhaps in the denominator, I can't recall.
> And in the degenerate case where n=k,
> "common sense" tells us that we get the
> right answer if 0! is arbitrarily defined
> to be 1. So we do that.

Pretty much any way you define the factorial function, you always end up
with some form of the relationship:

X! = X * (X - 1)!

Or, put another way:

(X - 1)! = X! / X

So, for X == 1:

0! = 1! / 1

- Warren Brown