OFFSET
1,1
COMMENTS
The generalization of Wilson's Theorem that x!*(p-1-x)! is either +1 or -1 mod p when p is prime is known. This is investigated here for cases of p such that there is an x with x!*(p-1-x)! congruent to either +1 or -1 mod p^2.
LINKS
Robert Israel, Table of n, a(n) for n = 1..4011
EXAMPLE
0!*4! + 1 = 5^2 and 4+0 = 5-1, so 5 is in the sequence.
1!*9! - 1 = 11^2*2999 and 1+9 = 10-1, so 11 is in the sequence.
0!*12! + 1 = 13^2*2834329 and 0+12 = 13-1, so 13 is in the sequence.
10!*6! + 1 = 17^2*83*108923 and 10+6=17-1, so 17 is in the sequence.
19!*39!-1 is divisible by 59^2 and 19+39=59-1, so 59 is in the sequence.
MAPLE
filter:= proc(p) local m, n, A, v;
A:= Array(0..p);
A[0]:= 1:
for n from 1 to p do A[n]:= n*A[n-1] mod p^2 od:
for m from 0 to (p-1)/2 do
v:= A[m] * A[p-1-m] mod p^2;
if v = 1 or v = p^2-1 then return true fi;
od;
false
end proc:
select(filter, [seq(ithprime(i), i=1..150)]); # Robert Israel, Dec 30 2024
PROG
(PARI) isok(p)={if(isprime(p), for(m=0, p\2, my(t=(m!*(p-1-m)!%p^2)); if(t==1||t==p^2-1, return(1)))); 0} \\ Andrew Howroyd, Oct 22 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Richard Peterson, Oct 22 2024
EXTENSIONS
a(14) onwards from Andrew Howroyd, Oct 22 2024
STATUS
approved