# For any prime number $n >5$, prove the final digit of $n^4$ is $1$

So I am struggling a bit with this question

$n$ is prime

we can ignore $2$ and $5$ as $n>5$

now if $n$ is prime

for the digits: $\{0,1,2,3,4,5,6,7,8,9\}$

$\{0,2,4,6,8\}$ can be discounted as $n$ cannot be even that

$5$ can be discounted as $n$ is not a multiple of $5$ either

therefore any prime must have the last digit $q$ such that $q\subset\{1,3,7,9\}$

For $n^4$, if $n=10p+q$

for a natural number $p$

I don't quite know how I can get to the desired result.

• Just compute $n^4 = (10p + q)^4$ and divide by $10$. The only part that isn't divisible by $10$ is $q^4$, and you can compute the last digits of $1^4, 3^4, 7^4,$ and $9^4$. – user296602 Jun 11 '18 at 15:29
• $240 | (n^4 - 1)$ (and $240$ is the greatest possible here). – metamorphy Jun 11 '18 at 15:36

If $n$ is prime $p>5$ then $$n\equiv \pm1,\pm 3 \pmod{10}$$ that is final digit of $n$ is $1,3,7$ or $9$, so $$n^2\equiv \pm1 \pmod{10}$$ that is final digit of $n^2$ is $1$ or $9$, so $$n^4\equiv 1 \pmod{10}$$ that is final digit of $n^4$ is $1$.
This results directly from Euler's theorem: if $n$ is any integer coprime to $10$, $$n^{\varphi(10)}=n^4\equiv 1\mod 10,$$ and precisely, if $n$ is a prime number $>5$, it is coprime to $10$.
Hint $$n^4-1=(n^2-1)(n^2+1)=(n^2-1)(n^2-4+5)\\ =(n^2-1)(n^2-4)+5(n-1)(n+1)\\ =(n-2)(n-1)(n+1)(n+2)+5(n-1)(n+1)$$
Show that $$10| (n-2)(n-1)(n+1)(n+2) \,, \mbox{ and }\\ 10|5(n-1)(n+1)$$
On the claim I've done in my comment above: for a prime $n > 5$ we have $$n \equiv 1 \pmod 2 \Rightarrow n^2 \equiv 1 \pmod 8 \Rightarrow n^4 \equiv 1 \pmod{16};$$ $$n^2 \equiv 1 \pmod 3 \Rightarrow n^4 \equiv 1 \pmod 3;\quad n^4 \equiv 1 \pmod 5$$ (the last two are implied by FLT, or may be verified by hand, considering each possible residue $\bmod {3, 5}$), so $n^4 \equiv 1 \pmod{240}$, and $240 = \gcd(7^4 - 1, 11^4 - 1)$ is the greatest possible.