Modular Exponentiation

622 views
Skip to first unread message

Santanu Sarkar

unread,
Mar 17, 2011, 1:44:53 AM3/17/11
to sage-s...@googlegroups.com
How one can calculate a^b mod c in Sage for large b?

Robert Bradshaw

unread,
Mar 17, 2011, 1:58:44 AM3/17/11
to sage-s...@googlegroups.com
mod(a, c)^b

On Wed, Mar 16, 2011 at 10:44 PM, Santanu Sarkar
<sarkar.sa...@gmail.com> wrote:
> How one can calculate  a^b mod c  in Sage for large b?
>

> --
> To post to this group, send email to sage-s...@googlegroups.com
> To unsubscribe from this group, send email to sage-support...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org
>

Graham Enos

unread,
Mar 17, 2011, 1:26:05 PM3/17/11
to sage-support
Another option is to use the pow() function, as in pow(a, b, c).

On Mar 17, 1:58 am, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Robert Bradshaw

unread,
Mar 17, 2011, 1:45:11 PM3/17/11
to sage-s...@googlegroups.com
Yep, looking at Integer.__pow__

def __pow__(self, n, modulus):
if modulus is not None:
from sage.rings.finite_rings.integer_mod import Mod
return Mod(self, modulus) ** n

so that should be exactly the same thing.

Reply all
Reply to author
Forward
0 new messages