RosettaCodeData/Task/Ethiopian-multiplication/Relation/ethiopian-multiplication.relation
2023-07-01 13:44:08 -04:00

25 lines
386 B
Text

function half(x)
set result = floor(x/2)
end function
function double(x)
set result = 2*x
end function
function even(x)
set result = (x/2 > floor(x/2))
end function
program ethiopian_mul(a,b)
relation first, second
while a >= 1
insert a, b
set a = half(a)
set b = double(b)
end while
extend third = even(first) * second
project third sum
end program
run ethiopian_mul(17,34)
print