%I #43 May 12 2023 08:38:11
%S 1,2,3,4,6,8,9,11,12,16,24,32,33,36,44,48,64,96,128,132,144,176,192,
%T 256,384,512,528,576,704,768,1024,1536,2048,2112,2304,2816,3072,4096,
%U 6144,8192,8448,9216,11264,12288,16384,24576,32768,33792,36864,45056,49152,65536,98304,131072,135168,147456
%N Numbers k such that whenever the sum of three squares is divisible by k, at least two of the squares are congruent mod k.
%C 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).
%H Mathematics Stack Exchange, <a href="https://math.stackexchange.com/questions/4490010/sum-of-squares-and-quadratc-residues/4490041">Sum of squares and quadratic residues</a>
%e 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.
%e 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.
%p filter:= proc(n) local R,i,j,nR,a,b,c;
%p R:= {seq(i^2 mod n, i=0..n-1)}:
%p nR:= nops(R);
%p for i from 2 to nR do
%p a:= R[i];
%p for j from 1 to i-1 do
%p b:= R[j];
%p c:= -a-b mod n;
%p if member(c,R) and c <> a and c <> b then return false fi;
%p od od;
%p true
%p end proc:
%p select(filter, [$1..100000]);
%t 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];
%t Select[Range[10000], filter] (* _Jean-François Alcover_, May 12 2023, after _Robert Israel_ *)
%K nonn
%O 1,2
%A _Robert Israel_, Jul 10 2022