Ethiopian multiplication: Difference between revisions

→‎{{header|OCaml}}: Removed after being incorrect for a month. (Unfortunately i don't know OCaml to fix it).
No edit summary
(→‎{{header|OCaml}}: Removed after being incorrect for a month. (Unfortunately i don't know OCaml to fix it).)
Line 1,009:
return 0;
}</lang>
 
=={{header|OCaml}}==
{{incorrect|OCaml|program needs to define three functions to halve double and test odd/even as stated in the task description.}}
<lang ocaml>let ethiopicmult x y =
let rec aux plier pliand acc =
if plier = 0
then (acc)
else
if plier mod 2 = 0
then aux (plier / 2) (pliand * 2) acc
else aux (plier / 2) (pliand * 2) (acc + pliand)
in
aux x y 0</lang>
 
'''Usage example''' from the interpreter
<pre># ethiopicmult 17 34;;
- : int = 578</pre>
 
=={{header|Octave}}==
Anonymous user