Difference of 2 squares

A number-theoretic property

About Difference of 2 squares

An integer can be written as a difference of two perfect squares, n = a² − b² = (a − b)(a + b), if and only if n is not congruent to 2 (mod 4). So every odd number and every multiple of 4 has such a representation; numbers of the form 4k + 2 do not.

Key features

  • Odd numbers: e.g. 3 = 2² − 1², 5 = 3² − 2².
  • Multiples of 4: e.g. 8 = 3² − 1².
  • Numbers of the form 4k + 2 (e.g. 2, 6, 10) cannot be written as a difference of two squares.

Examples:

3, 5, 8, 15, 21

Further reading