Sometime ago I discovered the following function for computing primes:
$$ Q(x)=\text{frac} \left (\cfrac{\Gamma(x)}{x} \right )\cfrac{x^2}{x-1}= \begin{cases} x & \small \text{if $x$ is prime} \\ 0 & \small \text{otherwise} \end{cases} $$
where "$\text{frac}$" is fractional part and $\Gamma$ is Gamma function. Is there a way to prove that formula is correct?
Regards
Wilson's theorem: $\Gamma(n) = (n-1)! \equiv -1 \mod n$ iff $n$ is prime. So if $n$ is prime, $\text{frac}(\Gamma(n)/n = (n-1)/n$.
Suppose $n$ is composite. For each prime $p$ dividing $n$, if $p^j$ is the highest power of $p$ dividing $n$, then $p^j$ also divides $\Gamma(n)$, and so $\Gamma(n)$ is divisible by $n$, with the sole exception $n = 4 = 2^2$. Thus if $n \ne 4$, $\text{frac}(\Gamma(n)/n) = 0$.