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 = φ(10) + 1 where φ(n) is the number of positive integers less than n and relatively prime to n.

Euler discovered the φ function and proved that if a and m are relatively prime, then

aφ(m) = 1 (mod m)

This means that aφ(m) – 1 is divisible by m. (Technically I should use the symbol ≡ (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 = αβ where α and β are distinct primes. In particular, we could choose α = 2 and β = 5; We will show that

aφ(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 φ(15) = 8.

We only need to be concerned with the case of a being a multiple of α or β since Euler’s theorem proves our theorem for the rest of the cases. If a = αβ our theorem obviously holds, so assume a is some multiple of α, a = kα with k less than β (and hence relatively prime to β).

We need to show that αβ divides (kα)φ(αβ)+1kα. This expression is clearly divisible by α, so the remaining task is to show that it is divisible by β. We’ll show that (kα)φ(αβ) – 1 is divisible by β.

Since α and k are relatively prime to β, Euler’s theorem tells us that αφ(β) and kφ(β) are congruent to 1 (mod β). This implies that kαφ(β) is congruent to 1, and so kαφ(α)φ(β) is also congruent to 1 (mod β). One of the basic properties of φ is that for relatively prime arguments α and β, φ(αβ) = φ(α)φ(β) 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?

Related: Applied number theory

5 thoughts on “When the last digits of powers don’t change

  1. Its most generalized form: The last digit of, any integer and its nth power, are the same, where n=4k+1.

  2. I first heard about this wonderful little nugget of mathematics from a YouTube video by Numberphile. It must come from the fact that the binomial expansion of the quintic power of a sum resolves beautifully as:

    ( a + 1 ) ^ 5 = ( a ^ 5 + 1 ) + 5 a ( a ^ 3 + 1 ) + 10 a ^ 2 ( a + 1 )

    so that if a is odd or even, then ( a ^ 3 + 1 ) is even or odd, respectively,and thus { a ( a ^ 3 + 1 ) } is always even, and thus 5 times that results in a term that is a multiple of 10, which the 3rd term does by inspection, thus

    ( a + 1 ) ^ 5 = ( a ^ 5 + 1 ) + 10 c

    [ ( a + 1 ) ^ 5 ] % 10 = ( a ^ 5 + 1 ) % 10

    which means that for any given number ‘a’, that number plus 1 taken to the 5th power has the same last digit as the 5th power of the given number plus 1, which proves the theorem for any number that is +1 from some number, and thus any number can be 0 to infinity, the theorem is proven for any number from 1 to infinity. For the sum to be 0, it is trivial to prove that any power is also 0, so it works as well.

    Q.E.D.

Leave a Reply

Your email address will not be published. Required fields are marked *