[Math] Find the units digit in the number $7^{9999}$.

congruenceselementary-number-theory

I have step by step instructions from a previous example to follow, so I figure I know how to get the answer, but I don't understand fully why it works the way it does…

By Euler's theorem, if $(a,m)=1$ then $a^{\varphi(m)}\equiv 1\mod{m}$. Here we have $(7,10)=1$ and $\varphi(10)=4$ Therefore, $7^4\equiv 1\mod{10}$.

$7^4\equiv 1\mod{10}\Longrightarrow 7^{4(2499)}\equiv 1^{2499}\mod{10}$

$7^{4(2499)+3}=(7^{4})^{2499}\cdot 7^3\equiv 1^{2499}\cdot 7^3\mod{10}$

$7^3=343\equiv 3\mod{10}.$

Therefore, the units digit in the number $7^{9999}$ is $3$.

The biggest part I don't understand is why I was able to "cancel" the $7^{4(2499)}$ from both sides of the congruence. The cancellation law states that if $cx\equiv cy\mod{m}$ and $(c,m)=1$ then $x\equiv y\mod{m}$… But I don't see a common $c$ on either side of the congruence.

Best Answer

It's not cancelling out

If $(a,n)=1,a^{\phi(n)}\equiv1\pmod n$ by Euler's

Now if $b$ is any integer, $$a^{b\cdot\phi(n)+c}=\left(a^{\phi(n)}\right)^b\cdot a^c\equiv1^b\cdot a^c\pmod n\equiv a^c$$

Related Question