## Task $9 / 64$

Let $p$ be an integer that is not divisible by 2, 3, or 5. What is the remainder when $p^{4}$ is divided by 240?
To investigate divisibility, the number $p^{4}-1$ is formed and factored as follows:

$$
p^{4}-1=\left(p^{2}-1\right)\left(p^{2}+1\right)=(p-1)(p+1)\left(p^{2}+1\right)
$$

1. Since $p$ is not divisible by 2, it follows that $p^{2}$ is also not divisible by 2, but $p-1, p+1$, and $p^{2}+1$ are. Since $p-1$ and $p+1$ are two consecutive even numbers, exactly one of them is divisible by 4. This implies that $p^{4}-1$ is divisible by 16.
2. The numbers $p-1, p, p+1$ are three consecutive integers. Exactly one of them is divisible by 3. Since this is not $p$, it must be either $p-1$ or $p+1$. This implies that $p^{4}-1$ is divisible by 3.
3. Since $p$ is not divisible by 5, it follows that either $p=5k \pm 1$ or $p=5k \pm 2$ with $k=0; 1; 2; 3; \ldots$ This implies either

$$
p^{2}=25k^{4} \pm 10k+1 \quad \text{or} \quad p^{2}=25k^{4} \pm 20k+1
$$

and thus either

$$
p^{2}-1=25k^{4} \pm 10k \quad \text{or} \quad p^{2}+1=25k^{4} \pm 20k
$$

We see that in either case, exactly one of the two factors $p^{2}-1$ or $p^{2}+1$, and thus the product $p^{4}-1$, is divisible by 5.

From 1., 2., and 3., it follows that $p^{4}-1$ is divisible by $16 \cdot 3 \cdot 5=240$. Therefore, under the given conditions, $p^{4}$ always leaves a remainder of 1 when divided by 240.