Ethiopian multiplication: Difference between revisions
Content added Content deleted
(→{{header|x86 assembly}}: ++ unix shell) |
(→{{header|J}}: ++ a rather rough recursive haskell approach) |
||
Line 178: | Line 178: | ||
end program EthiopicMult</lang> |
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}}== |
=={{header|J}}== |