Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,8 +1,8 @@
|
|||
T binomial(T)(in T n, T k) pure /*nothrow*/ {
|
||||
T binomial(T)(in T n, T k) pure nothrow {
|
||||
if (k > (n / 2))
|
||||
k = n - k;
|
||||
T bc = 1;
|
||||
foreach (T i; cast(T)2 .. k + 1)
|
||||
foreach (T i; T(2) .. k + 1)
|
||||
bc = (bc * (n - k + i)) / i;
|
||||
return bc;
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ T binomial(T)(in T n, T k) pure /*nothrow*/ {
|
|||
void main() {
|
||||
import std.stdio, std.bigint;
|
||||
|
||||
foreach (d; [[5, 3], [100, 2], [100, 98]])
|
||||
foreach (const d; [[5, 3], [100, 2], [100, 98]])
|
||||
writefln("(%3d %3d) = %s", d[0], d[1], binomial(d[0], d[1]));
|
||||
writeln("(100 50) = ", binomial(100.BigInt, 50.BigInt));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue