Evaluate binomial coefficients: Difference between revisions
Content added Content deleted
Line 1,039: | Line 1,039: | ||
<lang scala>object Binomial extends App { |
<lang scala>object Binomial extends App { |
||
def binomialCoefficient(n: Int, k: Int) = |
def binomialCoefficient(n: Int, k: Int) = |
||
(BigInt(n - k + 1) to |
(BigInt(n - k + 1) to n).product / |
||
(BigInt(1) to |
(BigInt(1) to k).product |
||
val Array(n, k) = args.map(_.toInt) |
val Array(n, k) = args.map(_.toInt) |