Ethiopian multiplication: Difference between revisions
Content added Content deleted
(→{{header|GW-BASIC}}: Marked incorrect) |
(Updated D code) |
||
Line 705: | Line 705: | ||
=={{header|D}}== |
=={{header|D}}== |
||
⚫ | |||
Works with DMD V.2.051. |
|||
⚫ | |||
pure nothrow int ethiopian(int n1, int n2) |
pure nothrow int ethiopian(int n1, int n2) |
||
in { |
|||
assert(n1 >= 0, "muliplier cannot be negative"); |
|||
} body { |
|||
static pure nothrow int doubleNum(in int n) { return n * 2; } |
|||
static pure nothrow int halveNum(in int n) { return n / 2; } |
|||
static pure nothrow bool isEven(in int n) { return !(n % 2); } |
|||
int result; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
unittest { |
unittest { |