# The final digit of fourth powers

I am working on "Elementary Number Theory" By Underwood Dudley and this is problem 13 in Section 4.

The question is "What can the last digit of a fourth power be?" I got the correct answer but I'm wondering if there is another more elegant way to do it. I'm also wondering if my argument is solid or if I just got the right answer by chance. My argument is as follows:

Any number A can be written as:

$A$ = $10^kn_k$ + $10^{k-1}$$n_{k-1}$ + $...$ + $10n_1$ + $n_0$,

where $n_k$ is the starting digit of the number and can take on any integer from 0 to 9 and so forth.

If we raise this to the fourth power and don't combine any of the terms, each term should be divisible by 10 except maybe not $n_0^4$. Now, $n_0^4$ must end must end in k where k satisfies:

$n_0^4$ $\equiv k\pmod {10}$.

And since $n_0^4$ ends in k, $A$ must end in k (since all of the other terms in the sum are divisible by 10). So, it suffices to just check what the last digit of the fourth powers of 1 through 9 are (since $0 \leq n_0 \leq 9$):

$0^4$ $\equiv 0\pmod{10}$

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

$2^4 \equiv 6\pmod{10}$

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

$4^4 \equiv 6\pmod{10}$

$5^4 \equiv 5\pmod{10}$

$6^4 \equiv 6\pmod{10}$

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

$8^4 \equiv 6\pmod{10}$

$9^4 \equiv 1\pmod{10}$.

So the fourth power of any integer must end in either a 0,1,5, or 6.

Did I get lucky or is this ok? Are there other more elegant ways?

Thank you!

• You mean, final digits of fourth powers, not of powers of four. And you are correct, this works for any positive integer exponent. – Travis Willse Aug 29 '14 at 17:38
• Thank you. I made the correction. – candido Aug 29 '14 at 17:40

That looks fine, though you could have shortened the argument by noting that the last digit of a product depends only on the last digit of each factor, and hence the same goes for powers.

You could have shortened it further by considering fourth powers modulo 2 and modulo 5. You can get either 0 or 1 modulo 2 (obviously), and the same goes modulo 5 (slightly less obviously, but you could use Fermat' little theorem if you felt super lazy).

Combining the two results gives you 0, 1, 5, 6 modulo 10 as you have found.

• Great points, thank you. – candido Aug 29 '14 at 17:46
• @candido In fact one can similarly use little Fermat mod $\,2p\,$ for any prime $\,p,\,$ not only $\,p=5,\,$ see my answer. – Bill Dubuque Aug 29 '14 at 18:21

Correct. More generally, using little Fermat, we can compute $\,a^{p-1}\, {\rm mod}\ 2p\,$ for any odd prime $p$

$\qquad 2\mid a,\, p\mid a\ \Rightarrow\ a^{p-1}\equiv 0,0\,\ {\rm mod}\ 2,p\ \Rightarrow\ a^{p-1}\equiv 0\,\ {\rm mod}\ 2p$

$\qquad 2\nmid a,\, p\nmid a\ \Rightarrow\ a^{p-1}\equiv 1,1\,\ {\rm mod}\ 2,p\ \Rightarrow\ a^{p-1}\equiv 1\,\ {\rm mod}\ 2p$

$\qquad 2\nmid a,\, p\mid a\ \Rightarrow\ a^{p-1}\equiv 1,0\,\ {\rm mod}\ 2,p\ \Rightarrow \ a^{p-1}\equiv p\,\ {\rm mod}\ 2p$

$\qquad 2\mid a,\, p\nmid a\ \Rightarrow\ a^{p-1}\equiv 0,1\,\ {\rm mod}\ 2,p\ \Rightarrow\ a^{p-1}\equiv p\!+\!1\,\ {\rm mod}\ 2p$

Thus the final digit of $\,a^{p-1}$ in radix $\,2p\,$ is $\,\in\{ 0,\, 1,\, p,\, p\!+\!1\}\$ [$= \{0,1,5,6\}$ in radix $10$]

You probably shouldn't reuse the variable $k$ for 2 different things. Other than that, your proof is fine. Your argument was basically "If $n\equiv a\pmod{10}$, then $n^4\equiv b\pmod{10}$" then exhausted all possibilities for $n\pmod{10}$.

As the other answer suggests, you could have used Fermat's Little Theorem. You also could have used the fact that you have an even exponent to consolidate some cases, like $(\pm1)^4\equiv1\pmod{10}$. That narrows $10$ cases down to $6$.

The last one, two, or three ending digits of perfect 4th powers must be:

ending digit: 0,1,5,6

last 2 ending digits: 00,01,21,41,61,81,25,16,36,56,76,96

last 3 ending digits: 000, 001, 201, 401, 601, 801, 121, 321, 521, 721, 921, 041, 241, 441, 641, 841, 161, 361, 561, 761, 961, 081, 281, 481, 681, 881, 625, 016, 216, 416, 616, 816, 136, 336, 536, 736, 936, 056, 256, 456, 656, 856, 176, 376, 576, 776, 976, 096, 296, 496, 696, 896.

The list continues.................