login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Numbers k such that both k and k^2 + 2 can be written as the sum of two nonzero squares.
0

%I #21 Sep 15 2022 02:17:29

%S 40,68,72,104,148,180,320,392,468,544,612,648,720,788,832,900,936,968,

%T 1040,1044,1156,1192,1256,1300,1332,1508,1732,1796,1800,1832,1872,

%U 1940,2056,2196,2308,2336,2372,2448,2664,2696,2740,2804,2848,2880,3060,3200,3280

%N Numbers k such that both k and k^2 + 2 can be written as the sum of two nonzero squares.

%C The terms in this sequence can be considered as a solution to the "near miss" problem which occurs frequently while solving Diophantine equations. It is known that if a number k can be written as the sum of two nonzero distinct squares then so can k^2 and k^2+1. Thus, finding numbers k such that k^2+2 satisfies the same property makes it quite interesting.

%e 40 is a term since 40 = 2^2 + 6^2 as well as 40^2 + 2 = 1602 = 9^2 + 39^2.

%e 320 is a term since 320 = 8^2 + 16^2 as well as 320^2 + 2 = 102402 = 201^2 + 249^2.

%o (PARI) is1(n)= for( i=1, #n=factor(n)~%4, n[1, i]==3 && n[2, i]%2 && return); n && ( vecmin(n[1, ])==1 || (n[1, 1]==2 && n[2, 1]%2)); \\ A000404

%o isok(k) = is1(k) && is1(k^2+2); \\ _Michel Marcus_, Jul 18 2022

%o (Python)

%o from itertools import count, islice

%o from sympy import factorint

%o def A355778_gen(startvalue=1): # generator of terms >= startvalue

%o for n in count(max(startvalue, 1)):

%o c = False

%o for p in (f:=factorint(n)):

%o if (q:= p & 3)==3 and f[p]&1:

%o break

%o elif q == 1:

%o c = True

%o else:

%o if c or f.get(2, 0)&1:

%o c = False

%o for p in (f:=factorint(n**2+2)):

%o if (q:= p & 3)==3 and f[p]&1:

%o break

%o elif q == 1:

%o c = True

%o else:

%o if c or f.get(2, 0)&1:

%o yield n

%o A355778_list = list(islice(A355778_gen(),30)) # _Chai Wah Wu_, Sep 14 2022

%Y Cf. A000290, A000404, A000415.

%K nonn

%O 1,1

%A _Angad Singh_, Jul 16 2022