Given a polynomial f(x)=x(x+1)(x+2)(x+3)+1 Given a polynomial $f(x)=x(x+1)(x+2)(x+3)+1$ and $p$ an odd prime, prove that it exists a number $n$ such that $p$ divides $f(n)$ if and only if it exists an integer $m$ such that $p$ divides $m^2-5$.

You have that
$$f(x) = x(x + 1)(x + 2)(x + 3) + 1 \tag{1}\label{eq1A}$$
Since $p$ is an odd prime, then any $n$ with $p \mid f(n)$ is true iff only $p \mid 16f(n)$. Multiply $f(n)$ by $16$ and distribute the powers of $2$ to each factor with $n$ in it to get
$$16f(n) = (2n)(2n + 2)(2n + 4)(2n + 6) + 16 \tag{2}\label{eq2A}$$
Hint: Now, let

$$m = 2n + 3 \tag{3}\label{eq3A}$$

to get

$$\begin{equation}\begin{aligned}16f(n) = g(m) & = (m - 3)(m - 1)(m + 1)(m + 3) + 16 \\ & = (m - 3)(m + 3)(m - 1)(m + 1) + 16 \\ & = (m^2 - 9)(m^2 - 1) + 16 \\& = m^4 - 10m^2 + 9 + 16 \\& = m^4 - 10m^2 + 25 \\ & = (m^2 - 5)^2\end{aligned}\end{equation}\tag{4}\label{eq4A}$$

Thus $p \mid (m^2 - 5)^2$ and, since $p$ is a prime, this means $p \mid m^2 - 5$.
For the other direction, for any $m$ where $p \mid m^2 - 5$, if $m$ is even, then use a new $m$ with $p$ added to it so it's odd but where you still have $p \mid m^2 - 5$. Hint for remainder of the proof:

Then you can reverse the above steps in \eqref{eq4A} to get, from \eqref{eq3A}, that with the integer

$n = \frac{m - 3}{2}$, that $p \mid 16f(n) \implies p \mid f(n)$.

