If $2p+1$ is a prime number, then $(p!)^2+(-1)^p$ is divisible by $2p+1$.

I have a question which is as following:

If $2p+1$ is a prime number, then $(p!)^2+(-1)^p$ is divisible by $2p+1$.

Whenever I see questions involving factorial sign, I try to use Wilson theorem, but I don't know weather I can use it here or not, If yes then how??

Since it is given that $(2p+1)$ is a prime number. So we can use Wilson theorem for $2p+1$ as:

$$((2p + 1)-1)! + 1\equiv 0 \mod(2p + 1)$$

$$(2p)!+1\equiv 0 \mod(2p + 1)$$

$$1\times2\times3\times4\times5\times6....(p)\times(p + 1)\times(p + 2)....(2p - 1)\times(2p) + 1\equiv 0 \mod(2p + 1)$$

$$p! [(2p+1-p)]\times [2p+1-(p-1)]\times[2p+1-(p-2)]\times[2p+1-(1)]+1\equiv 0 \mod (2p+1)$$

$$p![M(2p + 1)+(-1)\times(p)\times(p-1)\times(p-2)....3\times2\times1] +1\equiv 0 \mod(2p + 1)$$

$$p![M(2p + 1)+(-1)^p {p!}] + 1\equiv 0 \mod(2p + 1)$$

$$[p!M(2p + 1)]+[(-1)^p {p!}^2] + 1\equiv 0 \mod(2p + 1)$$

Notice that $[p!M(2p + 1)]$ is already divisible by $(2p + 1)$, So,

$$[(-1)^p {p!}^2] + 1\equiv 0 \mod(2p + 1)$$

Which was needed to be proved.

:) :) :) :)

• I know that it is not written in good form, but it is nicely elaborated. +1 – Lelouch vi Britannia Dec 23 '16 at 14:11
• @LelouchviBritannia: Tread carefully. It is natural to give support to an answer by a classmate, but then there is a risk that your votes are seen as being tied to the identity of the poster as opposed to the quality of the post. Also, votes coming from the same IP address look suspicious and the system is monitoring those. For all we know you could be voting for yourself (I don't think you do, but it is hard to prove), and surely you understand that is something we do not allow. – Jyrki Lahtonen Dec 24 '16 at 19:42
• Hey @JyrkiLahtonen, Please come here – Vidyanshu Mishra Dec 24 '16 at 20:22

$p=2$ works. Suppose now $p\ge 3$. Then by Wilson's theorem $$(p!)^2= (-1)^p p!\cdot (-1)(-2)\cdots (-p)\equiv (-1)^p (2p)!\equiv (-1)^{p+1}\bmod{2p+1}.$$

By Wilson's theorem since $2p+1$ is a prime number, $(2p)!+1$ is divisible by $2p+1$. Put $n$ for $2p+1$, then $(2p)!$ may be written as, $$1\cdot (n-1)\cdot 2 \cdot (n-2) 3\cdot(n-3) \cdots p(n-p)$$ if these factors supposed be multiplied out, it is obvious that we obtain $(-1)^p1^22^23^2\cdots p^2$ together with some multiple of $n$.

Hence, $1+(-1)^p(p!)^2$ must be divisible by $n$ and therefore $(p!)^2 + (-1)^p$ must be divisible by $n$, i.e, $2p+1$. Hope it helps.