Library/Number Theory/Divisibility rules/Divisibility rules for 2 and 4

Divisibility rules for 2 and 4

Overview

Divisibility by 2

A number is divisible by 22 iff its last digit is even (0, 2, 4, 6, 8).

Divisibility by 4

A number is divisible by 44 iff the number formed by its last two digits is divisible by 44.

Why the “last few digits” rules work: 10k=2k5k10^k = 2^k \cdot 5^k

Write a positive integer in base 10:

N=d0+d110+d2102++dn10n.N = d_0 + d_1\cdot 10 + d_2\cdot 10^2 + \cdots + d_n\cdot 10^n.

Since 10=2510 = 2 \cdot 5, we have 10k=2k5k10^k = 2^k \cdot 5^k. So 2a10k2^a \mid 10^k exactly when kak \ge a (the factor 2a2^a appears in 10k10^k). So modulo 2a2^a:

  • 100=110^0 = 1 is not divisible by 22 (only k1k \ge 1 gives 210k2 \mid 10^k).
  • 100,10110^0, 10^1 are not both divisible by 44; 102,103,10^2, 10^3, \ldots are divisible by 44.
  • 103,104,10^3, 10^4, \ldots are divisible by 88; only the last three digits matter.
  • 104,105,10^4, 10^5, \ldots are divisible by 1616; only the last four digits matter.

So:

DivisorDepends only on last … digits
221 (last digit)
442
883
16164

Examples

  • 1857218\,572 is divisible by 22 (last digit 22).
  • 72367\,236 is divisible by 44 (last two digits 3636).
  • 21362\,136 is divisible by 88 (last three digits 136=8×17136 = 8 \times 17).
  • 1204812\,048 is divisible by 1616 (last four digits 2048=16×1282048 = 16 \times 128).