I've been asked to compute the value of an expression in the form of $a^b$ (mod $c$), where $a, c$ are prime and $b$ is extremely large. How would I use modular arithmetic to do so? I'm thinking that Fermat's Theorem might be helpful, but not sure how.
Asked
Active
Viewed 184 times
0
-
Do you know Euler's Theorem $a^{\phi(c)} \equiv 1 \pmod{c}$ for $\gcd(a,c) = 1$? – Calvin Lin Dec 16 '19 at 16:26
-
I don't believe we've learned that. – dampen_the_riot Dec 16 '19 at 16:26
-
Ah, $c$ is prime, so you're fine. – Calvin Lin Dec 16 '19 at 16:27
-
1Does this answer your question? How do I compute $a^b,\bmod c$ by hand? – The Demonix _ Hermit Dec 16 '19 at 16:28
-
very common question. – Dec 16 '19 at 16:29
-
it's only for prime b that you can't resort to repeated exponentiation without addition. – Dec 16 '19 at 16:52