OFFSET
2,2
COMMENTS
Solutions mod p are represented by integers from 0 to p-1. The following equivalences hold for n > 1: There is a prime p such that n is a solution mod p of x^2 = 2 iff n^2-2 has a prime factor > n; n is a solution mod p of x^2 = 2 iff p is a prime factor of n^2-2 and p > n. n^2-2 has at most one prime factor > n, consequently such a factor is the only prime p such that n is a solution mod p of x^2 = 2. For n such that n^2-2 has no prime factor > n (the zeros in the sequence), cf. A060515.
LINKS
Robert Israel, Table of n, a(n) for n = 2..10000
FORMULA
If n^2-2 has a (unique) prime factor p > n, then a(n) = p, else a(n) = 0.
EXAMPLE
a(11) = 17, since 11 is a solution mod 17 of x^2 = 2 and 11 is not a solution mod p of x^2 = 2 for primes p < 17. Although 11^2 = 2 mod 7, prime 7 is excluded because 7 < 11 and 11 = 4 mod 7.
MAPLE
f:= proc(n) local P;
P:= select(`>`, numtheory:-factorset(n^2-2), n);
if P = {} then 0 else min(P) fi
end proc:
map(f, [$2..100]); # Robert Israel, Feb 23 2016
MATHEMATICA
a[n_] := Module[{P}, P = Select[FactorInteger[n^2 - 2][[All, 1]], # > n&]; If[P == {}, 0, Min[P]]];
Table[a[n], {n, 2, 100}] (* Jean-François Alcover, Apr 10 2019, from Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Klaus Brockhaus, Feb 21 2001
EXTENSIONS
Offset corrected by R. J. Mathar, Aug 21 2009
STATUS
approved