= Solution
<Wilson's theorem> states that for a prime $p$, $(p-1)!\equiv-1\pmod p$. For odd $p$, pair each nonzero <residue> with its multiplicative inverse. Only the self-inverse residues remain unpaired; $x^2=1$ in a field gives $x=\pm1$. Their product is $-1$, proving the result. For $p=2$ the assertion is immediate.
If composite $n\ge6$ is not the square of a prime, choose a prime divisor $p$ such that $p$ and $n/p$ are distinct. Both occur among the factors of $(n-1)!$, so their product $n$ divides it. In the remaining case $n=p^2$, $p\ge3$, and the two distinct factors $p,2p$ both occur in the factorial and have product divisible by $p^2$. Thus the factorial is zero modulo every such composite $n$.
For prime $n$, Wilson's congruence makes the numerator sine squared equal $\sin^2(\pi/n)$, so its ratio is one. For composite $n\ge6$, the numerator vanishes. The only exceptional composite in the sum is four; its ratio is $\sin^2(3\pi/2)/\sin^2(\pi/4)=2$. Therefore for $x\ge4$ the sum counts the primes plus two, and subtracting two gives exactly the required prime count. All statements concern the integers $2\le n\le\lfloor x\rfloor$.
Back to article page