I recently found the following function, that returns $1$ if its argument is a prime number, and $0$ otherwise. Let $\chi_{\mathbb{P}}: \mathbb{Z}\rightarrow\{0,1\}$ for $n>4$ be defined as follows: $$ \chi_{\mathbb{P}}(n)=\frac{(-1)^{\frac{2}{n}\Gamma(n)}-1}{(-1)^{-\frac{2}{n}}-1}. $$ Then $\chi_{\mathbb{P}}$ is the characteristic function of the primes. Note that here $\Gamma$ denotes the usual gamma function.
The first few values, starting from $n=5$ are the following:
1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, ...
For convenience I include the relevant Mathematica code here:
Table[((-1)^(2 Gamma[n]/n) - 1)/((-1)^(-2/n) - 1), {n, 5, 20}]
Is this already known? I have not found references to it in literature.
There, it is given: ("
For n > 4, a(n) = (n-2)! mod n. - Thomas Ordowski, Jul 24 2016")$$\space n\gt 4,\space a(n) = \Gamma(n-1)\pmod n$$
Which is the closest expression to your expressions that is listed there. Both this expression and yours, are a consequence of Wilson's theorem.
– Vepir Oct 12 '19 at 13:25