# Why the last digit of $a^n$ is equal to the last digit of $a$ raised to power of $n$?

$$17^3 = 4913$$, and $$7^3 = 343$$, they share the same last digit.

$$15^4 = 50625$$, and $$5^4 = 625$$. Also the same last digit, the question is why do they share the same last digit?

• Have you heard of cyclicity? This is a phenomenon that motivated a lot of the origins of abstract algebra. – Don Thousand Apr 19 at 21:04
• Try doing this multiplication by hand and all will become clear :) – Jair Taylor Apr 19 at 21:24
• Do you know modular arithmetic or congruences? – Bill Dubuque Apr 19 at 21:53

Because if $$l$$ is the last digit of $$a$$, then $$a$$ cab be written as $$10b+l$$ for some natural $$b$$ and therefore, by the binomial formula,$$a^n=(10b+l)^n=\overbrace{10^nb^n+\binom n110^{n-1}b^{n-1}l+\cdots+\binom n{n-1}10bl^{n-1}}^{\text{multiple of }10}+l^n.$$
The operation of "taking the last digit" is like finding the remainder after division by $$10$$ -- or in math speak it is like taking the number modulo $$10$$. The great thing about modular arithmetic is that it respects all of the basic operation you typically like to, namely addition and multiplication (and therefore exponentiation). This means you can either exponentiate and then find the remainder, or you can find a remainder and then exponentiate, and you can even mix and match if your expression is really large. This in fact forms the basis of many modular exponentiation algorithms used in cryptography.