Power with modulu

Mitja nun at example.com
Sun Dec 5 21:50:23 CET 2004


On Sun, 05 Dec 2004 12:59:40 +0200, Roie Kerstein  
<sf_kersteinroie at bezeqint.net> wrote:

> Hello!
>
> I want to compute a**b%c for very long numbers.
> Computing a**b and then applying modulu is not practical, since it takes
> ages.
> There is a built-in optional parameter to the long.__pow__(a,b[,modulu]),
> and it works well.
> My question is: How can I write it is a form of an expression, like a**b?
AFAIK you can't.

> I prefer not to fill my script with calls of the form  
> long.__pow__(a,b,c).
That's a bit ugly, yes; pow is also a builtin, e.g.:
pow(21,443,2)==1


-- 
Mitja



More information about the Python-list mailing list