Ethiopian multiplication: Difference between revisions

→‎{{header|J}}: ++ a rather rough recursive haskell approach
(→‎{{header|J}}: ++ a rather rough recursive haskell approach)
Line 178:
 
end program EthiopicMult</lang>
 
=={{header|Haskell}}==
<lang haskell>ethiopicmult 1 pliand acc = acc + pliand
ethiopicmult plier pliand acc =
if (plier `mod` 2) == 0
then ethiopicmult (plier `div` 2) (pliand * 2) acc
else ethiopicmult (plier `div` 2) (pliand * 2) (acc + pliand)</lang>
 
'''Usage example''' from the interpreter
<pre>*Main> ethiopicmult 17 34 0
578</pre>
 
=={{header|J}}==