OFFSET
1,4
COMMENTS
The following sequences all appear to have the same parity (with an extra zero term at the start of A010051): A010051, A061007, A035026, A069754, A071574. - Jeremy Gardiner, Aug 09 2002
In particular, this is identical to the isprime function A010051 except for a(4) = 2 instead of 0. This is equivalent to Wilson's theorem, (n-1)! == -1 (mod n) iff n is prime. If n = p*q with p, q > 1, then p, q < n-1 and (n-1)! will contain the two factors p and q, unless p = q = 2 (if p = q > 2 then also 2p < n-1, so there are indeed two factors p in (n-1)!), whence (n-1)! == 0 (mod n). - M. F. Hasler, Jul 19 2024
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
a(4) = 2 since -(4 - 1)! = -6 = 2 mod 4.
a(5) = 1 since -(5 - 1)! = -24 = 1 mod 5.
a(6) = 0 since -(6 - 1)! = -120 = 0 mod 6.
MATHEMATICA
Table[Mod[-(n - 1)!, n], {n, 100}] (* Alonso del Arte, Mar 20 2014 *)
PROG
(PARI) A061007(n) = ((-((n-1)!))%n); \\ Antti Karttunen, Aug 27 2017
(PARI) apply( {A061007(n) = !(n-1)!%n}, [0..99]) \\ M. F. Hasler, Jul 19 2024
(Python)
from sympy import isprime
def A061007(n): return 2 if n == 4 else int(isprime(n)) # Chai Wah Wu, Mar 22 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Henry Bottomley, Apr 12 2001
STATUS
approved