floor, 105 bytes
F:x->floor x r:x->1/(x-F x) I:x->1+F(F x-x) p:k->(F k*r k)+1/(r k-1) f:n->(n-1)*I(F p^(n-2)(1+1/(n-1))/n) returns nonzero for primes and zero for non-primes
Explanation
Ungolfed version:
intPair: x y -> x + 1/y left: x -> floor x right: x -> 1/(x-floor x) is_int: x -> 1+floor(floor x - x) fakt_1: n_k -> intPair ((left n_k)*(right n_k)) (right n_k - 1) f: n -> (n-1)*is_int( (left fakt_1^(n-2) intPair 1 (n-1))/n) Uses Wilson's theorem to determine if the input is a prime number
fakt_1^(n-2) intPair 1 (n-1) computes (n-1)!+1 (abusing that storing one in the second component of a pair, will increase the first component by 1)
The rest of f checks if (n-1)!+1 is evenly divisible by n and returns 1 if yes and zero otherwise. The multiplication with (n-1) is to ensure that 1 is not falsely detected as prime
Implementation:
To run the program, execute the Python-script with the arguments
-f <source-file> -- <input-number>
floor, 116 bytes
f applies prime_step n-2 times to the pair (n,2) which will return 0 if n is divisible by any integer between 2 and n-1 and n otherwise. The multiplication with lt 1 n is there to ensure that f(1) will return 0
Implementation:
To run the program, execute the Python-script with the arguments
-f <source-file> -- <input-number>