OFFSET
1,2
COMMENTS
By definition, when n > 1, a(n) = 0 then n is a Wilson prime (A007540).
For a(n) to equal 1, (n-1)! must be divisible by n^2 which is the prevailing case for large n. For example, all n which are a product of more than two distinct primes belong to this category. So do all proper powers of primes except 2^2, 2^3, and 3^2. Obviously, when a(n) = 1, then also A055976(n) = 1.
The cases of a(n) > 1 include, for example, all primes other than Wilson's and all numbers of the form n=2*p, where p is a prime.
LINKS
Stanislav Sykora, Table of n, a(n) for n = 1..10000
Wikipedia, Wilson prime
FORMULA
a(n) = ((n-1)! + 1) mod n^2. - Jon E. Schoenfield, Mar 18 2018
EXAMPLE
From Muniru A Asiru, Mar 20 2018: (Start)
((1-1)! + 1) mod 1^2 = (0! +1) mod 1 = 2 mod 1 = 0.
((2-1)! + 1) mod 2^2 = (1! +1) mod 4 = 2 mod 4 = 2.
((3-1)! + 1) mod 3^2 = (2! +1) mod 9 = 3 mod 9 = 3.
((4-1)! + 1) mod 4^2 = (3! +1) mod 16 = 7 mod 16 = 7.
((5-1)! + 1) mod 5^2 = (4! +1) mod 25 = 25 mod 25 = 0.
... (End)
MAPLE
seq((factorial(n-1)+1) mod n^2, n=1..60); # Muniru A Asiru, Mar 20 2018
MATHEMATICA
Array[Mod[(# - 1)! + 1, #^2] &, 67] (* Michael De Vlieger, Apr 21 2018 *)
PROG
(PARI) a(n) = ((n-1)! + 1) % n^2; \\ Michel Marcus, Mar 18 2018
(GAP) List([1..60], n->(Factorial(n-1)+1) mod n^2); # Muniru A Asiru, Mar 20 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Stanislav Sykora, Mar 18 2018
STATUS
approved