Anonymous user
Ethiopian multiplication: Difference between revisions
→{{header|ActionScript}}
(→{{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>
var res:int = 0;▼
while (a > 0) {▼
function Divide(a:Number):Number {
return
}
function Multiply(a:Number):Number {
return (a *= 2);
return res;▼
}
}</lang>▼
function isEven(a:Number):Boolean {
if (a%2 == 0) {
} else {
return (false);
}
}
function Ethiopian(left:Number, right:Number) {
trace(left+" "+right);
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);
}
}
=={{header|Ada}}==
|