When the last digits of powers don’t change
If you raise any integer to the fifth power, its last digit doesn't change. For example, 25 = 32.
It's easy to prove this assertion by brute force. Since the last digit of bn only depends on the last digit of b, it's enough to verify that the statement above holds for 0, 1, 2, ", 9.
Although that's a valid proof, it's not very satisfying. Why fifth powers? We're implicitly working in base 10, as humans usually do, so what is the relation between 5 and 10 in this context? How might we generalize it to other bases?
The key is that 5 = I(10) + 1 where I(n) is the number of positive integers less than n and relatively prime to n.
Euler discovered the I function and proved that if a and m are relatively prime, then
aI(m) = 1 (mod m)
This means that aI(m) - 1 is divisible by m. (Technically I should use the symbol a (U+2261) rather than = above since the statement is a congruence, not an equation. But since Unicode font support on various devices is disappointing, not everyone could see the proper symbol.)
Euler's theorem tells us that if a is relatively prime to 10 then a4 ends in 1, so a5 ends in the same digit as a. That proves our original statement for numbers ending in 1, 3, 7, and 9. But what about the rest, numbers that are divisible by 2 or 5? We'll answer that question and a little more general one at the same time. Let m = II^2 where I and I^2 are distinct primes. In particular, we could choose I = 2 and I^2 = 5; We will show that
aI(m)+1 = a (mod m)
for all a, whether relatively prime to m or not. This would show in addition, for example, that in base 15, every number keeps the same last "digit" when raised to the 9th power since I(15) = 8.
We only need to be concerned with the case of a being a multiple of I or I^2 since Euler's theorem proves our theorem for the rest of the cases. If a = II^2 our theorem obviously holds, so assume a is some multiple of I, a = kI with k less than I^2 (and hence relatively prime to I^2).
We need to show that II^2 divides (kI)I(II^2)+1 - kI. This expression is clearly divisible by I, so the remaining task is to show that it is divisible by I^2. We'll show that (kI)I(II^2) - 1 is divisible by I^2.
Since I and k are relatively prime to I^2, Euler's theorem tells us that II(I^2) and kI(I^2) are congruent to 1 (mod I^2). This implies that kII(I^2) is congruent to 1, and so kII(I)I(I^2) is also congruent to 1 (mod I^2). One of the basic properties of I is that for relatively prime arguments I and I^2, I(II^2) = I(I)I(I^2) and so we're done.
Exercise: How much more can you generalize this? Does the base have to be the product of two distinct primes?