Ethiopian multiplication: Difference between revisions

(→‎{{header|ActionScript}}: Marked incorrect as the task asks for three functions to be defined and used in the solution)
Line 53:
=={{header|ActionScript}}==
{{incorrect|ActionScript|Task asks for three functions to be defined and used in the solution.}}
<lang ActionScript>public function Multiply(a:int,b:int):int {
 
var res:int = 0;
 
while (a > 0) {
function Divide(a:Number):Number {
if (a & 1) res += b;
return ((a = -(a %2))/ 2);
}
b = b * 2;
function Multiply(a:Number):Number {
}
return (a *= 2);
return res;
}
}</lang>
function isEven(a:Number):Boolean {
if (a%2 == 0) {
return res(true);
} else {
return (false);
}
}
function Ethiopian(left:Number, right:Number) {
var resr:intNumber = 0;
trace(left+" "+right);
while (aleft >!= 01) {
var State:String = "Keep";
if (isEven(Divide(left))) {
State = "Strike";
}
trace(Divide(left)+" "+Multiply(right)+" "+State);
left = Divide(left);
right = Multiply(right);
if (State == "Keep") {
r += right;
}
}
trace("="+" "+r);
}
}
}</lang>
 
=={{header|Ada}}==
Anonymous user