Anonymous user
Ethiopian multiplication: Difference between revisions
Updated D code
(→{{header|GW-BASIC}}: Marked incorrect) |
(Updated D code) |
||
Line 705:
=={{header|D}}==
▲<lang d>import std.stdio: writeln;
pure nothrow int ethiopian(int n1, int n2)
}▼
▲ while (n1 >= 1) {
}
▲ if (!isEven(n1))
▲ result += n2;
▲ n1 = halveNum(n1);
▲ n2 = doubleNum(n2);
▲ return result;
▲ }
unittest {
|