Is this a new characteristic function for the primes?
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.
Solution 1:
As $n\in\Bbb Z^+$, if $\chi_{\Bbb P}(n)=1$ then $$\chi_{\mathbb{P}}(n)=\frac{(-1)^{2\Gamma(n)/n}-1}{(-1)^{-2/n}-1}=\frac{(-1)^{2(n-1)!/n}-1}{(-1)^{-2/n}-1}=1\implies (-1)^{2(n-1)!/n}=(-1)^{-2/n}$$ which is equivalent to $$\frac{2(n-1)!}n\equiv-\frac2n\pmod2\implies2\cdot\left(\frac{(n-1)!+1}{n}\right)\equiv0\pmod2$$ which is true if the term in brackets is an integer; that is, if $n\mid (n-1)!+1$, which in turn is equivalent to Wilson's Theorem.
Note that on the other hand, $$\chi_{\Bbb P}(n)=0\implies\frac{2(n-1)!}n\equiv0\pmod2\implies n\mid(n-1)!$$ so $n$ cannot be prime.
Solution 2:
Yes, this is a variant of Wilson's theorem.