Ethiopian multiplication: Difference between revisions

Added Perl 6.
(return is a keyword, not a function)
(Added Perl 6.)
Line 914:
 
print ethiopicmult(17,34, 1), "\n";</lang>
 
=={{header|Perl 6}}==
{{works with|Rakudo|#21 "Seattle"}}
 
<lang perl6>sub halve (Int $n is rw) { $n div= 2 }
sub double (Int $n is rw) { $n *= 2 }
sub even (Int $n --> Bool) { $n % 2 == 0 }
 
sub ethiopicmult (Int $a is copy, Int $b is copy --> Int) {
my Int $r = 0;
while $a {
even $a or $r += $b;
halve $a;
double $b;
}
return $r;
}</lang>
 
=={{header|PHP}}==
Line 949 ⟶ 966:
 
?></lang>
 
 
=={{header|PL/SQL}}==
845

edits