Fermat's theorem on sums of two squares states that an odd prime number \( p \) can be expressed as the sum of two squares (i.e., there exist integers \( x \) and \( y \) such that \( p = x^2 + y^2 \)) if and only if \( p \equiv 1 \mod 4 \) or \( p = 2 \).