Ethiopian multiplication: Difference between revisions
Content deleted Content added
Updated D entry |
|||
Line 926:
=={{header|D}}==
<lang d>int ethiopian(int n1, int n2) pure nothrow▼
<lang d>import std.stdio;▼
▲int ethiopian(int n1, int n2) pure nothrow
in {
assert(n1 >= 0, "
} body {
static
static
static
int result;
Line 945 ⟶ 943:
return result;
} unittest {▼
▲unittest {
assert(ethiopian(77, 54) == 77 * 54);
assert(ethiopian(8, 923) == 8 * 923);
Line 954 ⟶ 950:
void main() {
writeln("17 ethiopian 34 is ", ethiopian(17, 34));
}</lang>
{{out}}
<pre>17 ethiopian 34 is 578</pre>
|