Ethiopian multiplication: Difference between revisions
Content added Content deleted
(Undo revision 65955. No better or worse than the references given. Certainly should not be put at the head of the task.) |
(return is a keyword, not a function) |
||
Line 184: | Line 184: | ||
<lang awk>function halve(x) |
<lang awk>function halve(x) |
||
{ |
{ |
||
return |
return int(x/2) |
||
} |
} |
||
function double(x) |
function double(x) |
||
{ |
{ |
||
return |
return x*2 |
||
} |
} |
||
function iseven(x) |
function iseven(x) |
||
{ |
{ |
||
return |
return x%2 == 0 |
||
} |
} |
||
Line 207: | Line 207: | ||
plicand = double(plicand) |
plicand = double(plicand) |
||
} |
} |
||
return |
return r |
||
} |
} |
||