# Why is the last digit of $n^5$ equal to the last digit of $n$?

I was wondering why the last digit of $n^5$ is that of $n$? What's the proof and logic behind the statement? I have no idea where to start. Can someone please provide a simple proof or some general ideas about how I can figure out the proof myself? Thanks.

• Because $\varphi(10)=4$. Aug 20, 2012 at 12:55
• Since the question has been answered satisfacorily, I would just like to mention the deeper reason why the last digit stays the same. Assuming the last digit is $d$, we want to show that $d^5$ has last digit $d$, i.e., $d^5 \equiv d \mod 10$. Applying the Chinese Remainder Theorem, this is equivalent to showing $d^5 \equiv d \mod 2, 5$. For the first case, $5 \equiv 1 \mod 2$, so the claim follows directly. In the second case, $5 = 4 + 1 = \phi(5) + 1$, so the claim follows by Fermat's theorem. Aug 20, 2012 at 12:56
• @kloos Mod 2, $a^k \equiv a$ for all $a$ and all $k$, of course - needn't use any other property. Aug 20, 2012 at 13:34
• @Kloos: The second case follows immediately from Fermat's theorem, doesn't it? What does $5 = 4 + 1 = \phi(5) + 1$ have to do with it? Aug 20, 2012 at 18:58
• Note that the reason it's 5 is because we are in base 10. If we were in base 12, 6^n would end in 6 since it's 1/2 of 12. You'd also find some very neat patterns in the way 3, 4, 8 and 9 work because they are 1/3, 1/4, 2/3 and 3/4 of 12. Aug 20, 2012 at 20:44

Alternatively, you could prove that $n^5-n$ is divisible by $10$ by induction. If $n=0$, it is obviously true.

Assume true for $n$, we need to show that:

$$(n+1)^5-(n+1) = n^5 + 5n^4 + 10n^3 + 10n^2 + 5n + 1 - (n+1) \\=n^5 - n + 10(n^3+n^2) +5n(n^3+1)$$

is divisible by 10.

But $n^5-n$ is divisibly by $10$ by induction, and $10(n^3+n^2)$ is obviously divisible by $10$, so all you need to show is that $5n(n^3+1)$ is divisible by $10$, which is the same as proving that $n(n^3+1)$ is divisible by $2$.

The fundamental reason for this, as everybody has noted, is due to rules of modular arithmetic.

• I get it! :) Thanks a bunch. Aug 20, 2012 at 18:21
• I would say, n(n^3+1) because either n is even, in which case n times anything is even, or n is odd, in which case n^3 is odd and (n^3+1) is even. Aug 20, 2012 at 20:23
• @Malvolio Yep, I was just leaving a step out for the OP. Aug 20, 2012 at 21:03

Note, the last digit of $n^5$ can only be affected by the last digit of $n$. That is, the 1s digit of any power of $n$ will only be affected by the ones digit of $n$, and not the 10s, 100s, or any other digit. So, you only have 10 cases, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. All you have to do is try them separately. $0^5 = 0$, $1^5 = 1$, $2^5 = 32$, $3^5 = 243$, ..., $9^5 = 59049$.

If you've heard of modular arithmetic, all numbers mod 10 are going to be in the set $\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\}$. And, this is why we only need consider these 10 cases.

• Okay but why is it mod 10? What's the purpose behind mod 10? Aug 20, 2012 at 13:02
• @gekkostate: because $n \pmod 10$ is the last digit of $n$, being the remainder when $n$ is divided by $n$ Aug 20, 2012 at 13:09
• @gekkostate Because, our number system is base 10. So, a 3 in the 10s place is equivalent to $3 * 10$, and a 7 in the 10,000s place is equivalent to $7 * 10^5$. So, when we take things mod 10, all that remains is the units digit. Aug 20, 2012 at 14:22

$$n^5-n=n(n^4-1)=n(n^2-1)(n^2+1)=n(n^2-1)(n^2-4+5)$$ $$=n(n^2-1)(n^2-4)+5n(n^2-1)$$ $$=\underbrace{(n-2)(n-1)n(n+1)(n+2)}_{\text{ product of }5\text{ consecutive integers }}+5\cdot \underbrace{(n-1)n(n+1)}_{\text{ product of }3\text{ consecutive integers }}$$

Now, we know the product $r$ consecutive integers is divisible by $r!$ where $r$ is a positive integer

So, $(n-2)(n-1)n(n+1)(n+2)$ is divisible by $5!=120$ and $(n-1)n(n+1)$ is divisible by $3!=6$

$$\implies n^5-n\equiv0\pmod{30}\equiv0\pmod{10}$$

I won't explain you that it's true because you discovered it was true !

Fermat's little theorem tells us that : $$k^5\equiv k\pmod{5}$$ Further $k^5$ will be even or odd when $k$ is even or odd.
You may use the chinese remainder theorem to conclude that indeed : $$k^5\equiv k\pmod{10}$$ (this works because of the factorization $10=2\cdot 5$ and that is why other small primes won't share this property...)

We may produce this table of powers with that property : $$1, 5, 9, 13, 17, 21\cdots$$ The pattern is clear : you'll get the same result for $p=4n+1$ with $n\in \mathbb{N}$.
This is natural since mulplying each digit $k$ by $k^4$ will give $k$ again.

• What I love about this is that not only will $n^1,5,9,...$ end in $n$, but if you observe the in between powers, there is always a four number cycle. e.g. for $3^k, k->\infty$, we observe the numbers $3, 9, 27, 81, 243, 729, 2187, 6561, 19683, ...$, rendering the cycle $3, 9, 7, 1$. Aug 20, 2012 at 19:30
• @KenB: the periodicity of the digits must divide $5-1=4$ so that $1^k\to 1,1,\cdots$, $2^k \to 2,4,8,6,2\cdots$ but $4^k\to 4,6,4\cdots$ (period $1,2,4$ are possible). You may too change the rules a little and compute $\pmod{33}$ for example (the table of powers will be $1,11,21\cdots$) or better play directly with Group Theory (it's fun too !). Aug 20, 2012 at 20:06

If $\gcd(a, n) = 1$ then by Euler's theorem,

$$a^{\varphi(n)} \equiv 1 \pmod{n}$$

From the tables and as @SeanEberhard stated, $$\varphi(10) = \varphi(5*2) = 10\left( 1 - \frac{1}{5} \right) \cdot \left(1 - \frac{1}{2} \right)$$

$$= 10\left(\frac{4}{5} \right) \cdot \left(\frac{1}{2} \right) = 4$$

Let $n=10$ and thus,

$$a^{\varphi(10)} \equiv 1 \pmod{10} \implies a^{4} \equiv 1 \pmod{10}$$

Multiply both sides by $a$,

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

The claim is clearly equivalent to the claim that $n^5 - n$ is divisible by $10$.

By Fermat's little theorem, $n^5 - n$ is divisible by $5$.

$n^5 - n = n(n^4 - 1)$ is even because if $n$ is odd, then $n^4-1$ is even.

Thus, $n^5 - n$ is divisible by both $5$ and $2$, and, these being coprime, it follows that $n^5 - n$ is divisible by $10$.

Numbers whose last digits of powers occur in cycles of 4:
21 = 2
22 = 4
23 = 8
24 = 6
25 = 2

31 = 3
32 = 9
33 = 7
34 = 1
35 = 3

71 = 7
72 = 9
73 = 3
74 = 1
75 = 7

81 = 8
82 = 4
83 = 2
84 = 6
85 = 8

Alternating last digits
41 = 4
42 = 6
43 = 4

91 = 9
92 = 1
93 = 9

Powers of numbers ending in 1,5,6 will always end in 1,5,6. Therefore we can observe from the above cases that,
n^5 and n will always have the same last digit.