This commit is contained in:
Ingy döt Net 2013-04-10 16:57:12 -07:00
parent 518da4a923
commit 764da6cbbb
6144 changed files with 83610 additions and 11 deletions

View file

@ -0,0 +1,9 @@
binomial_coefficient = (n, k) ->
result = 1
for i in [0...k]
result *= (n - i) / (i + 1)
result
n = 5
for k in [0..n]
console.log "binomial_coefficient(#{n}, #{k}) = #{binomial_coefficient(n,k)}"

View file

@ -0,0 +1,7 @@
> coffee binomial.coffee
binomial_coefficient(5, 0) = 1
binomial_coefficient(5, 1) = 5
binomial_coefficient(5, 2) = 10
binomial_coefficient(5, 3) = 10
binomial_coefficient(5, 4) = 5
binomial_coefficient(5, 5) = 1