Sub topic 12
Units digit patterns of powers
What this chapter covers and what it assumes
This chapter shows how to find the last digit of a large power, such as the units digit of 7^243, without computing the number. It assumes you are comfortable with integer exponents, the product rule for exponents, and division with remainders. You should also know how to tell whether a number is even or odd.
GRE questions of this type ask for the units digit, or sometimes the remainder when a power is divided by 10. The two are the same thing. The units digit of a positive integer is its remainder when divided by 10.
Why the units digit repeats
Multiplying two integers gives a units digit that depends only on the units digits of the factors. For example, 47 × 63 ends in the same digit as 7 × 3 = 21, so it ends in 1.
Because of this, when you compute successive powers of a number, only the last digit of the previous power matters. There are only ten possible last digits, so the sequence must eventually repeat. Once a last digit appears a second time, every later digit repeats in the same order. The repeating block is called the cycle, and its length is the cycle length.
Here is the cycle for powers of 7:
| n | 7^n | Units digit |
|---|---|---|
| 1 | 7 | 7 |
| 2 | 49 | 9 |
| 3 | 343 | 3 |
| 4 | 2401 | 1 |
| 5 | 16807 | 7 |
| 6 | 117649 | 9 |
The units digits run 7, 9, 3, 1, then repeat. The cycle length is 4.
# The units digit of 7**n repeats every 4 powers
cycle = [pow(7, n, 10) for n in range(1, 9)]
assert cycle == [7, 9, 3, 1, 7, 9, 3, 1]The call pow(7, n, 10) returns 7^n mod 10, which is the units digit.
The cycles for every digit
Each possible units digit of the base has its own cycle. Only the units digit of the base matters, so 13^n has the same last digits as 3^n.
| Base ends in | Cycle of units digits (n = 1, 2, 3, ...) | Cycle length |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 1 |
| 2 | 2, 4, 8, 6 | 4 |
| 3 | 3, 9, 7, 1 | 4 |
| 4 | 4, 6 | 2 |
| 5 | 5 | 1 |
| 6 | 6 | 1 |
| 7 | 7, 9, 3, 1 | 4 |
| 8 | 8, 4, 2, 6 | 4 |
| 9 | 9, 1 | 2 |
Every cycle length is 1, 2, or 4. Since 1 and 2 both divide 4, you can treat every base as having a cycle of length 4. This lets you use one rule for all bases and avoids memorizing the length for each digit.
# Every units digit repeats with period 1, 2, or 4, so period 4 works for all
for d in range(10):
for n in range(1, 21):
assert pow(d, n, 10) == pow(d, n + 4, 10)The procedure
To find the units digit of b^n, where n is a positive integer:
- Take the units digit of b.
- Divide the exponent n by 4 and find the remainder r.
- If r is 1, 2, or 3, the answer is the units digit of that digit raised to the power r.
- If r is 0, the answer is the units digit of that digit raised to the power 4. This is the last entry in the cycle.
Step 4 is the most common error. A remainder of 0 does not mean the power is 0. It means you are at the end of a full cycle, so use the fourth position.
Worked example 1
Find the units digit of 7^243.
- The base ends in 7.
- 243 = 4 × 60 + 3, so the remainder is 3.
- The third entry in the cycle 7, 9, 3, 1 is 3.
The units digit is 3.
Worked example 2
Find the units digit of 2^100.
- The base ends in 2.
- 100 is divisible by 4, so the remainder is 0.
- Use position 4 of the cycle 2, 4, 8, 6, which is 6.
The units digit is 6.
Worked example 3
Find the units digit of 38^57 + 19^30.
Handle each term separately, then add the last digits.
- 38^57: the base ends in 8. 57 = 4 × 14 + 1, so the remainder is 1. The first entry of 8, 4, 2, 6 is 8.
- 19^30: the base ends in 9. The cycle is 9, 1, and 30 is even, so the result is 1. With the length-4 rule, 30 = 4 × 7 + 2, and the second entry of 9, 1, 9, 1 is 1.
The sum ends in 8 + 1 = 9.
def units_digit(base, exponent):
d = base % 10
r = exponent % 4
if r == 0:
r = 4
return (d ** r) % 10
assert units_digit(7, 243) == 3
assert units_digit(2, 100) == 6
assert (units_digit(38, 57) + units_digit(19, 30)) % 10 == 9
assert units_digit(38, 57) == pow(38, 57, 10)Edge cases and common errors
- Adding digits that sum past 9. When you add or multiply the units digits of separate terms, keep only the last digit of the result. If two terms end in 7 and 6, their sum ends in 3, not 13.
- Using a remainder of 0 as the exponent. As noted above, replace a remainder of 0 with 4.
- Reading the base incorrectly. Only the last digit of the base matters, but the whole exponent matters. Do not reduce the exponent by looking at its last digit alone. For the cycle of length 4, you need the exponent's last two digits, because 100 is divisible by 4. So 4 divides n exactly when the number formed by the last two digits of n is divisible by 4.
- Exponent zero. The cycle pattern starts at n = 1. Any nonzero base raised to the 0 power is 1, whatever its units digit.
- Negative bases. The units digit of a negative integer is not defined in the same way on the GRE. If you see a negative base, work with the positive power first, then apply the sign rule for even and odd exponents.
- Exponent is itself a power. For a tower such as 3^(2^5), first compute the exponent 2^5 = 32, then reduce it. Here 32 has remainder 0 when divided by 4, so use position 4: the cycle 3, 9, 7, 1 gives 1.
# Exponent that is itself a power: 3**(2**5), exponent is 32
assert (2**5) % 4 == 0
assert units_digit(3, 2**5) == 1
assert pow(3, 2**5, 10) == 1Seeing the process
The flow below summarizes the procedure.
Use in Quantitative Comparison
Units digit questions often appear in Quantitative Comparison form. For example, Quantity A could be the units digit of 3^81 and Quantity B could be the units digit of 7^81.
- Quantity A: 81 = 4 × 20 + 1, so use position 1 of 3, 9, 7, 1, which is 3.
- Quantity B: position 1 of 7, 9, 3, 1 is 7.
Quantity B is greater. Because both quantities are fixed numbers, the answer is determined, so "cannot be determined" does not apply here.
Practice
Exercise
What is the units digit of 4^25 + 9^25?
Show answer
The base 4 has cycle 4, 6 (length 2), and 25 is odd, so 4^25 ends in 4. The base 9 has cycle 9, 1, and 25 is odd, so 9^25 ends in 9. The sum ends in 4 + 9 = 13, so the units digit is 3.
Exercise
What is the units digit of 13^102?
Show answer
Only the last digit of the base matters, so use 3 with cycle 3, 9, 7, 1. Divide 102 by 4: 102 = 4 × 25 + 2, so the remainder is 2. The second entry is 9, so the units digit is 9.
Exercise
What is the units digit of 6^1000 × 8^20?
Show answer
6^1000 ends in 6, since every power of 6 ends in 6. For 8^20, the remainder of 20 divided by 4 is 0, so use position 4 of 8, 4, 2, 6, which is 6. The product of the units digits is 6 × 6 = 36, so the units digit is 6.