RosettaCodeData/Task/Exponentiation-operator/PARI-GP/exponentiation-operator-1.parigp
2023-07-01 13:44:08 -04:00

9 lines
103 B
Text

ex(a, b)={
my(c = 1);
while(b > 1,
if(b % 2, c *= a);
a = a^2;
b >>= 1
);
a * c
};