5

For example,

$$123^{25} \pmod{10}$$

$$ 123 \equiv 3 \pmod{10}$$

$$123^{2} \equiv 9 \pmod{10}$$

$$123^{3} \equiv 7 \pmod{10}$$

$$123^{4} \equiv 1 \pmod{10}$$

$$123^{5} \equiv 3 \pmod{10}$$

It is easy to see:

$$123^n \equiv 123^{4(k) + n} \pmod{10}$$

$$4(6) = 4(k) = 24$$ Hence,

$$123^{1} \equiv 123^{4(6) + 1} \equiv 123^{25} \pmod{10} \equiv 3 \pmod{10}$$

My question is why does this work?

Amad27
  • 10,465
  • 1
    One could say it works "because of" Euler's Theorem, that $a^{\varphi(m)}\equiv 1\pmod{m}$ if $\gcd(a,m)=1$. Note that $\varphi(10)=4$. So $123^4\equiv 1\pmod{10}$. – André Nicolas Feb 26 '15 at 15:33

2 Answers2

2

Yes, $\,{\rm mod}\ 10\!:\ \color{#c00}{3^4\equiv 1}\,\Rightarrow\, 3^{J+4K}\!\equiv 3^J(\color{#c00}{3^4})^K\!\equiv 3^J\color{#c00}1^K\!\equiv 3^J $ by $ $ Congruence Power, Product Rules.

If $\,a\,$ is coprime to $\,m\,$ then $\ a^{\varphi(m)}\equiv 1\pmod{m}\ $ by Euler's Theorem. Therefore mod $\,m,\,$ the sequence of powers of $\,a\,$ will be periodic. The exact period length, i.e. the least $\,n\,$ such that $\,a^n\equiv 1\pmod m\,$ is known as the order of $\,a\ {\rm mod}\ m.\,$ It can be less than $\,\varphi(m),\,$ but must be divisor of $\,\varphi(m).$

Bill Dubuque
  • 272,048
0

First of all $123^n = (120+3)^n = (12\times10+3)^n = \sum_1^n \binom{n}{k}\times(12\times10)^k\times3^{n-k} \equiv 3^n \pmod {10}$, because all multiples of $10 \equiv 0 \pmod {10}$. So it's only needed to solve $3^{25} \pmod {10}$

This reduces it to $3^n \equiv 3^{n+4k} \pmod{10}$. Why $4$? As @André Nicolas stated, this is because of Euler's theorem saying $a^{\varphi(m)}\equiv 1 \pmod m$, if $\mathrm{gcd}(a,m) = 1$. This means $3^n \pmod {10}$ will only hit numbers coprime to $10$, and these are the four numbers $\{1,\,3,\,7,\,9\}$. None of these numbers share a divisor with $10$. This also means that $3^n \pmod {10}$ cannot hit $\{0,\,2,\,4,\,5,\,6,\,8\}$, since for instance there is no number $n$ such that $3^n = 4 \pmod{10}$. So since it can only hit the four numbers $\{1,\,3,\,7,\,9\}$, it will only do so, and repeat once it has hit the four numbers.

Frank Vel
  • 5,339