Power with modulu
Fredrik Lundh
fredrik at pythonware.com
Sun Dec 5 06:24:44 EST 2004
Roie Kerstein wrote:
> 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?
if you look up __pow__ in the documentation, you'll find that it explains
that __pow__ is used to implement the built-in pow() function:
http://docs.python.org/lib/built-in-funcs.html#l2h-54
in other words,
pow(a, b, c)
does what you want.
</F>
More information about the Python-list
mailing list