# Math Help - Modular Exponentiation

1. ## Modular Exponentiation

Hello,

I can't recall how to deal with large exponents in modular arithmetic.

Specifically, the question is to determine the value of 8^402 mod 5.

It is equivalent to (2^402 mod 5)^3 (since 2^3=8) from what I recall, but not sure how that helps...

Thanks!

2. Originally Posted by matt.qmar
Hello,

I can't recall how to deal with large exponents in modular arithmetic.

Specifically, the question is to determine the value of 8^402 mod 5.

It is equivalent to (2^402 mod 5)^3 (since 2^3=8) from what I recall, but not sure how that helps...

Thanks!
Here because 5 is prime we can use Fermat's Little Theorem and in general we can use Euler's theorem (which requires gcd of the base and the modulus to be 1).

So it's $8^{402}\equiv 3^{2}\equiv 4\pmod{5}$.