Ethiopian multiplication: Difference between revisions
→{{header|Haskell}}: Removed the multiplication operator from the definition of Ethiopian multiplication :-)
(Added Kotlin) |
(→{{header|Haskell}}: Removed the multiplication operator from the definition of Ethiopian multiplication :-)) |
||
Line 1,652:
=={{header|Haskell}}==
<lang haskell>import Prelude hiding (odd)
import Control.Monad (join)
halve
halve = (`div` 2)
double = (2 *)▼
odd :: Int -> Bool
odd = (== 1) . (`mod` 2)
ethiopicmult :: Integral a => a -> a -> a▼
(takeWhile (>= 1) $ iterate halve a)▼
ethiopicmult a b =
sum $
map snd $
filter (odd . fst) $
main :: IO ()
main = print $ ethiopicmult 17 34 == 17 * 34</lang>
{{Out}}
578</pre>
=={{header|HicEst}}==
|