in reply to Re: Binomial Expansion
in thread Binomial Expansion
You do say right away that is a valid formula for binomial coefficients, but then you say it's hardly a good one?
It is a formula for calculating r-combinations, not binomial coefficients.
The formula for binomial expansion is:
n
_
(x+y)^n = \ C(n,j) * x^(n-j) *y^j
/
¯
j=0
And btw, it is the definitive formula for calculating r-combinations. It's like saying 4/2 is not the same as 2. While 2 is a better way to write 4/2, not every one recognizes 2 right away, and I feel, for the benefit of the reader of me 'craft', n!/(r!(n-r)! is a better way to go.
As for your function, it is shorter, but a litle mysterious when it comes to the math.
update:9! 9*8*7* 6! 9*8*7 504 nCr(9,3) = --------- = ----------- = ------ = --- = 84 3!*(9-3)! 3*2*1*(6!) 3*2*1 6 which follows from the fact that nCr(n,r) = nCr(n,n-r) n! n! n! _ n! ------- = ----------------- = ------------- = --------- r!(n-r) (n-r)!(n-(n-r))! (n-r)!(n-n+r)! (n-r)!(r)!This however only works for n>r, as long as n and r are both non-negative integers, but shouldn't be a problem in this case.As for things being integer, since the input is an integer, it follows that any integer multiple of that integer, will also be an integer.
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re2: Binomial Expansion
by tye (Sage) on Mar 31, 2001 at 12:26 UTC | |
|
In theory, theory and practice are the same...
by tilly (Archbishop) on Mar 31, 2001 at 23:32 UTC | |
by tilly (Archbishop) on Apr 01, 2001 at 05:26 UTC | |
by tye (Sage) on Apr 01, 2001 at 08:09 UTC | |
by tilly (Archbishop) on Apr 01, 2001 at 18:56 UTC | |
by ariels (Curate) on Apr 11, 2001 at 10:55 UTC |