Jump to content

Ethiopian multiplication: Difference between revisions

no edit summary
(→‎{{header|PHP}}: -= added php output)
No edit summary
Line 702:
<pre>*Main> ethiopicmult 17 34
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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.