Ethiopian multiplication: Difference between revisions

Updated D code
(Updated D code)
Line 730:
<lang d>import std.stdio;
 
pure nothrow int ethiopian(int n1, int n2) pure nothrow
in {
assert(n1 >= 0, "muliplier cannot be negative");
} body {
static pure nothrow int doubleNum(in int n) pure nothrow { return n * 2; }
static pure nothrow int halveNum(in int n) pure nothrow { return n / 2; }
static pure nothrow bool isEven(in int n) pure nothrow { return !(n %& 21); }
 
int result;
Anonymous user