Primality of $n! +1$

I came across with a problem where I was required to examine primality of $n! +1$ (17! + 1 was the actual number).

Although Wilson’s Theorem could be manipulated for determining primality of $n! + 1$ when $n + 1$ is a prime and $n! – 1$ when $n + 2$ is a prime, it does not cover the specific example that I am dealing with. Is there any formula (or a more generalized formula that covers the whole problem space) for determining primality of $n! +1$ when $n + 1$ is not a prime?

Solutions Collecting From Web of "Primality of $n! +1$"