Quant Memo
Core

Finding the Last Digit of a Huge Power

The last digit of any power like 7 to the 2026th cycles in a short, predictable pattern — spotting and using that cycle turns an impossible-looking arithmetic question into a two-step calculation.

What is the last digit of 720267^{2026}? Computing 720267^{2026} directly is absurd — it has well over a thousand digits. But the question only asks for the last digit, and last digits of powers of any single-digit base repeat in a short cycle, because the last digit of a product depends only on the last digits of its factors. You never need the whole number, only its remainder when divided by 10.

The core idea: last digits cycle because multiplication "forgets" everything except the last digit

When you multiply two numbers, the last digit of the product depends only on the last digits of the two numbers being multiplied — the hundreds, thousands, and higher digits never affect it. So the sequence of last digits of 71,72,73,7^1, 7^2, 7^3, \dots is determined entirely by repeatedly multiplying the previous last digit by 7 and keeping only the new last digit. Since there are only 10 possible last digits, this process must eventually repeat — and for powers of a fixed base, the repeating cycle is usually short (length 1, 2, or 4 for base-10 last digits).

Working example: the cycle of powers of 7

71=77^1 = 7 (last digit 7). 72=497^2 = 49 (last digit 9). 73=3437^3 = 343 (last digit 3). 74=24017^4 = 2401 (last digit 1). 75=168077^5 = 16807 (last digit 7) — back to where we started. So the last digit of powers of 7 cycles with period 4: 7,9,3,1,7,9,3,1,7, 9, 3, 1, 7, 9, 3, 1, \dots

To find the last digit of 720267^{2026}, find where 2026 falls in this cycle of length 4 by computing the remainder of 2026 divided by 4: 2026=4×506+22026 = 4 \times 506 + 2, so 20262(mod4)2026 \equiv 2 \pmod 4. The exponent's position in the cycle is the same as exponent 2 (since the cycle restarts every 4 steps, and exponent 4 itself corresponds to position 4, i.e., the last entry). Exponent 2 in the cycle gives last digit 9 (from 72=497^2 = 49). So 720267^{2026} ends in 9.

Worked example 2: a base with a shorter cycle

What's the last digit of 820278^{2027}? Compute the cycle: 81=8,82=648^1=8, 8^2=64 (last digit 4), 83=5128^3 = 512 (last digit 2), 84=40968^4 = 4096 (last digit 6), 85=327688^5=32768 (last digit 8) — cycle length 4 again: 8,4,2,68,4,2,6. Find 2027mod42027 \bmod 4: 2027=4×506+32027 = 4 \times 506 + 3, so remainder 3, corresponding to the 3rd entry in the cycle: 2. So 820278^{2027} ends in 2. Note the general pattern across digits 0–9: last digits 0, 1, 5, 6 have cycle length 1 (they never change); 4 and 9 have cycle length 2; 2, 3, 7, 8 have cycle length 4 — worth memorizing as a shortcut so you don't need to recompute the cycle length from scratch each time.

7 9 3 1
Powers of 7 cycle through last digits 7, 9, 3, 1 with period 4; the exponent's remainder mod 4 selects which entry in the cycle applies.

To find the last digit of ana^n, find the (short, at most length-4) repeating cycle of last digits of powers of aa, then use nmod(cycle length)n \bmod (\text{cycle length}) to find where in the cycle nn falls — never compute the full power.

What this means in practice

This is the simplest entry point into modular arithmetic, the tool behind cryptographic checksums, hash functions, and any system that needs a fast, fixed-size fingerprint of a huge number. In an interview, it's also a speed test: recognizing "I only need the cycle" versus attempting brute-force multiplication under time pressure is exactly the kind of quick reframing that separates a fast, correct answer from a stalled one.

Memorize the cycle-length table by last digit — 1 for {0,1,5,6}\{0,1,5,6\}, 2 for {4,9}\{4,9\}, 4 for {2,3,7,8}\{2,3,7,8\} — so you can jump straight to computing nmod(cycle length)n \bmod (\text{cycle length}) without re-deriving the cycle from scratch every time.

Related concepts

Practice in interviews

Further reading

  • Niven, Zuckerman & Montgomery, An Introduction to the Theory of Numbers, ch. 2
ShareTwitterLinkedIn