Ethiopian multiplication: Difference between revisions

Content added Content deleted
Line 1,559: Line 1,559:
{Show {EthiopicMult 17 34}}</lang>
{Show {EthiopicMult 17 34}}</lang>


=={{header|PARI/GP}}==
<lang PARI/GP>halve(n)=n\2
double(n)=2*n
{{incorrect|PARI/GP|Task asks for three functions to be defined and used in the solution.}}
even(n)=!(n%2)
<lang PARI/GP>multE(a,b)={
my(t=0);
multE(a,b)={ my(d=0);
while(a,
while(a,
if (bitand(a,1), t += b);
if(!even(a),
b <<= 1;
d+=b);
a >>= 1;
a=halve(a);
b=double(b));
);
t
d
};</lang>
}</lang>


=={{header|Perl}}==
=={{header|Perl}}==