OFFSET
1,2
COMMENTS
There are more than n squares mod prime(n+1); therefore given a(n)=k we can choose a square r mod prime(n+1) that is not a(n)^2 mod prime(i) for i <= n, and using Chinese Remainder Theorem find x such that x == a(n) (mod prime(i)) for i <= n and x^2 == r (mod prime(n+1)), and then a(n+1) <= x. In particular a(n) exists for all n.
EXAMPLE
a(5) = 3 because 3^2 mod 2 = 1, 3^2 mod 3 = 0, 3^2 mod 5 = 4, 3^2 mod 7 = 2 and 3^2 mod 11 = 9 are all distinct, while this is not the case for 1^2 or 2^2 (e.g. 2^2 mod 5 = 2^2 mod 7 = 4).
MAPLE
P:= NULL:
v:= 1:
for n from 1 to 35 do
P:= P , ithprime(n);
for k from v do
if nops({seq(k^2 mod P[i], i=1..n)}) = n then
v:= k;
A[n]:= k;
break
fi
od
od:
seq(A[n], n=1..35);
PROG
(PARI) isok(k, n) = my(v=vector(n, j, lift(Mod(k, j)^2))); #v == #Set(v);
a(n) = {my(k=1); while(!isok(k, n), k++); k; } \\ Michel Marcus, Jul 12 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Jul 11 2019
STATUS
approved