(n - 1)! + 1 is divisible by n if n is prime or 1
EDIT: therefore floor ( cos pi ((n-1)!+1)/n )² is a boolean prime detector :3
You don’t actually need to rely on Wilson’s theorem to make a prime detector, a related and easier to prove (in fact it’s only half of the proof of Wilson’s theorem) theorem states that (n - 1)! is divisible by n if n is a composite number greater than 4.
Here’s my version of the boolean prime detector: (1-floor (cos pi ((n-1)! + 1)/n)²)(1-floor (1/(ceil|x-4|+1)))
It’s longer, but doesn’t rely on a theorem I don’t understand.