Ethiopian multiplication: Difference between revisions

Content added Content deleted
(→‎{{header|PHP}}: -= added php output)
No edit summary
Line 702: Line 702:
<pre>*Main> ethiopicmult 17 34
<pre>*Main> ethiopicmult 17 34
578</pre>
578</pre>

=={{header|HicEst}}==
<lang hicest> WRITE(Messagebox) ethiopian( 17, 34 )
END

FUNCTION ethiopian(x, y)
ethiopian = 0
left = x
right = y
DO i = x, 1, -1
IF( isEven(left) == 0 ) ethiopian = ethiopian + right
IF( left == 1 ) RETURN
left = halve(left)
right = double(right)
ENDDO
END

FUNCTION halve( x )
halve = INT( x/2 )
END

FUNCTION double( x )
double = 2 * x
END

FUNCTION isEven( x )
isEven = MOD(x, 2) == 0
END </lang>


=={{header|J}}==
=={{header|J}}==