OFFSET
2,1
COMMENTS
EXAMPLE
a(4) = 6 because 6 is not a quadratic residue modulo 7, but is a quadratic residue modulo 2, 3, and 5, and no smaller number works.
MAPLE
f:= proc(n) local k, p;
if issqr(n) then return -1 fi;
p:= 1;
for k from 1 do
p:= nextprime(p);
if numtheory:-quadres(n, p) = -1 then return k fi
od
end proc:
V:= Array(2..32): count:= 0:
for k from 2 while count < 31 do
v:= f(k);
if v > 0 and v <= 32 and V[v] = 0 then
V[v]:= k; count:= count+1
fi
od:
convert(V, list);
PROG
(Python)
from itertools import count
from math import isqrt
from sympy.ntheory import prime, nextprime, legendre_symbol
def A377212(n):
p = prime(n)
for r in count(1):
k, q = r+(m:=isqrt(r))+(r>=m*(m+1)+1), 2
while (q:=nextprime(q)):
if q>p or legendre_symbol(k, q)==-1:
break
if p==q:
return k # Chai Wah Wu, Oct 20 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Oct 19 2024
EXTENSIONS
a(33)-a(36) from Chai Wah Wu, Oct 21 2024
STATUS
approved