25 lines
386 B
Text
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
|