OFFSET
1,2
COMMENTS
If k is in the sequence and k = a*b with a and b coprime, then a and b are in the sequence. The converse is not true (thus 2 and 9 are in the sequence but 18 is not).
LINKS
Mathematics Stack Exchange, Sum of squares and quadratic residues
EXAMPLE
5 is not in the sequence because 0^2 + 1^2 + 2^2 = 5 is divisible by 5, with 0^2 = 0, 1^2 = 1 and 2^2 = 4 all distinct mod 5.
a(5) = 6 is in the sequence because the solutions to a^2 + b^2 + c^2 == 0 (mod 6) have (up to permutation) [a^2, b^2, c^2] == [0, 0, 0], [0, 3, 3], [1, 1, 4], or [4, 4, 4], all of which have at least two congruent mod 6.
MAPLE
filter:= proc(n) local R, i, j, nR, a, b, c;
R:= {seq(i^2 mod n, i=0..n-1)}:
nR:= nops(R);
for i from 2 to nR do
a:= R[i];
for j from 1 to i-1 do
b:= R[j];
c:= -a-b mod n;
if member(c, R) and c <> a and c <> b then return false fi;
od od;
true
end proc:
select(filter, [$1..100000]);
MATHEMATICA
filter[n_] := Module[{R, i, j, nR, a, b, c}, R = Union@ Table[Mod[i^2, n], {i, 0, n-1}]; nR = Length[R]; For[i = 2, i <= nR, i++, a = R[[i]]; For[j = 1, j <= i-1, j++, b = R[[j]]; c = Mod[-a-b, n]; If[MemberQ[R, c] && c != a && c != b, Return[False]]]]; True];
Select[Range[10000], filter] (* Jean-François Alcover, May 12 2023, after Robert Israel *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Jul 10 2022
STATUS
approved