Anonymous user
Ethiopian multiplication: Difference between revisions
→{{header|Mathematica}}
(→{{header|Go}}: fixed lang tag) |
|||
Line 1,304:
print(ethiopian(17, 34))</lang>
=={{header|Mathematica}}==
<lang Mathematica>IntegerHalving[x_]:=Floor[x/2]
IntegerDoubling[x_]:=x*2;
OddInteger OddQ
Ethiopian[x_, y_] :=
Total[Select[NestWhileList[{IntegerHalving[#[[1]]],IntegerDoubling[#[[2]]]}&, {x,y}, (#[[1]]>1&)], OddQ[#[[1]]]&]][[2]]
Ethiopian[17, 34]
->578</lang>
=={{header|Metafont}}==
|