Evaluate binomial coefficients: Difference between revisions

Updated D entry
m ('''See Also:''' * Pascal's triangle)
(Updated D entry)
Line 345:
 
=={{header|D}}==
<lang d>T binomial(T)(/*in*/ T n, T k) /*pure /*nothrow*/ {
<lang d>import std.stdio, std.bigint;
 
T binomial(T)(/*in*/ T n, T k) /*pure nothrow*/ {
if (k > (n / 2))
k = n - k;
Line 357 ⟶ 355:
 
void main() {
<lang d> import std.stdio, std.bigint;
 
foreach (d; [[5, 3], [100, 2], [100, 98]])
writefln("(%3d %3d) = %s", d[0], d[1], binomial(d[0], d[1]));
writeln("(100 50) = ", binomial(BigInt(100).BigInt, BigInt(50).BigInt));
}</lang>
{{out}}