OFFSET
1,1
COMMENTS
For more information see A336883.
LINKS
Hiroyuki Hara, Table of n, a(n) for n = 1..4783 [reformatted and restored by Georg Fischer, Oct 16 2020]
FORMULA
EXAMPLE
p(1)=5: (5-2)!=2*3=A336883(1)*a(1)==1 mod 5. 5=2+3.
p(2)=13: (13-2)!=(2*3*4*5*6)*(7*8*9*10*11)=(2*3*4*5*6)*((p-6)*(p-5)*(p-4)*(p-3)*(p-2))==5*(-5)==5*(13-5)=5*8==A336883(2)*a(2)==1 mod 13. 13=5+8.
a(n)=4: A336883(n)=(k*4+1)/(4-k)=(3*4+1)/(4-3)=13, k=3. p(n)=13+4=17.
a(n)=17: A336883(n)=(k*17+1)/(17-k)=(7*17+1)/(17-7)=12, k=7. p(n)=12+17=29.
MATHEMATICA
v = Select[Prime[Range[1000]], Mod[#, 4] == 1&];
v - Mod[((v-1)/2)!, v] (* Jean-François Alcover, Oct 24 2020, after PARI *)
PROG
(PARI) my(v=select(p->p%4==1, primes(100))); apply(x->x - (((x-1)/2)! % x), v) \\ Michel Marcus, Aug 07 2020
(Python) n_start=5
n_end=n_start+100000
k=1
for n in range(n_start, n_end, 4):
c=(n-1)//2
r=1
for i in range(2, c+1):
r=r*i % n
if r==0:
break
if (n-r)*r % n ==1:
print(k, n-r)
k = k + 1
# modified by Georg Fischer, Oct 16 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Hiroyuki Hara, Aug 06 2020
STATUS
approved