Problem

Source: Iberoamerican Olympiad 2005

Tags: number theory solved, number theory



Denote by $a \bmod b$ the remainder of the euclidean division of $a$ by $b$. Determine all pairs of positive integers $(a,p)$ such that $p$ is prime and \[ a \bmod p + a\bmod 2p + a\bmod 3p + a\bmod 4p = a + p. \]