Solution (source code)

= Solution

The <Chinese remainder theorem> says that for pairwise <coprime integers> $m_1,\ldots,m_r>0$, any prescribed residue modulo each $m_i$ is realized by exactly one residue class modulo $\prod_i m_i$. The <Fermat little theorem> says that for a <prime number> $q$ and an <integer> $a$ not divisible by $q$, $a^{q-1}\equiv1\pmod q$; equivalently, $a^q\equiv a\pmod q$ for every <integer> $a$.

For the given <prime number>, write $p=2k+1$. Its square is $p^2=1+4k(k+1)=1+8t$ for some <integer> $t$, since one of two consecutive <integers> is even. Therefore $p^4=(1+8t)^2\equiv1\pmod{16}$. The <Fermat little theorem> applied modulo $3$ gives $p^2\equiv1\pmod3$, hence $p^4\equiv1\pmod3$; applied modulo $5$ it gives $p^4\equiv1\pmod5$. These applications are valid because $p>5$.

The three moduli $16,3,5$ are pairwise <coprime integers> and have product $240$. By the <Chinese remainder theorem>,
$$
\boxed{p^4\equiv1\pmod{240}.}
$$