OFFSET
1,1
COMMENTS
Quadratic reciprocity says that for odd primes p and q, if p is a quadratic residue mod q then q is a quadratic residue mod p except in the case where p and q are both congruent to 3 (mod 4), in which case they can't both be quadratic residues mod each other. Thus if a(n-1) == 1 (mod 4), a(n) is the least prime > a(n-1) that is a quadratic residue mod a(n-1), while if a(n-1) == 3 (mod 4), a(n) is the least prime > a(n-1) that is congruent to 1 (mod 4) and is a quadratic residue mod a(n-1).
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(3) = 29 because a(2) = 7, 29 is a quadratic residue mod 7 and 7 is a quadratic residue mod 29, and 29 is the least prime > 7 that works.
MAPLE
f:= proc(p) local q;
q:= p;
do
q:= nextprime(q);
if NumberTheory:-QuadraticResidue(q, p) = 1 and NumberTheory:-QuadraticResidue(p, q) = 1 then return q fi
od
end proc:
A[1]:= 2: for i from 2 to 100 do A[i]:= f(A[i-1]) od:
seq(A[i], i=1..100);
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Jan 07 2023
STATUS
approved