This is a question from a French high school maths competition that I participated in today:
Let $n$ be a positive integer. Let $p$ be a prime number such that $$p^3 \text{ divides } (1^3 + 1)(2^3 + 1)\cdots\left((n-1)^3 + 1\right)(n^3 + 1).$$ Show that $p \leq n + 1$.
I have approached it by writing each $(n - i)^3 + 1$ in $\prod_{i = 0}^{n}\left((n - i)^3 + 1\right)$ as $(n - i + 1)\left((n - i)^2 - (n - i) + 1\right)$, and then the product then becomes $$\begin{aligned} &\prod_{i = 0}^n (n - i + 1)\left((n - i)^2 - (n - i) + 1\right)\\ &= (n + 1)! \prod_{i = 0}^n \left((n - i)^2 - (n - i) + 1\right) \end{aligned}$$
If for the sake of contradiction, $p \leq n + 1$ does not hold, then $p$ does not divide $(n + 1)!$ and hence $p^3$ divides $\prod_{i = 0}^n \left((n - i)^2 - (n - i) + 1\right)$. Sadly, I failed to find the contradiction.
My question is then: where is the contradiction? Is there a better approach?
It's easier to write the product as:
$$p^3|\prod_{i=1}^n(i^2-i+1).$$ Now, if $p>n+1$, then $p^2 >(n+1)^2\geq i^2-i+1. $ This means that there must be $1<i<j<k\leq n$ such that $p$ divides each of the factors corresponding to these indices. From this it is easy to get a contradiction. If $$p|i^2-i+1,\,\, j^2-j+1 $$ then their difference is also divisible by $p:$ $$p|(i-j)(i+j-1).$$ This also implies $$p|i+j-1.$$ Now do the same for the remaining possibilities and get a contradiction.