Ethiopian multiplication: Difference between revisions

no edit summary
No edit summary
Line 835:
===
578
 
==={{header|EMal}}===
<syntaxhighlight lang="emal">
fun halve = int by int value do return value / 2 end
fun double = int by int value do return value * 2 end
fun isEven = logic by int value do return value % 2 == 0 end
fun ethiopian = int by int multiplicand, int multiplier
int product
while multiplicand >= 1
if not isEven(multiplicand) do product += multiplier end
multiplicand = halve(multiplicand)
multiplier = double(multiplier)
end
return product
end
writeLine(ethiopian(17, 34))
</syntaxhighlight>{{out}}
578
 
==={{header|FreeBASIC}}===
224

edits