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”).

A355778
Numbers k such that both k and k^2 + 2 can be written as the sum of two nonzero squares.
0
40, 68, 72, 104, 148, 180, 320, 392, 468, 544, 612, 648, 720, 788, 832, 900, 936, 968, 1040, 1044, 1156, 1192, 1256, 1300, 1332, 1508, 1732, 1796, 1800, 1832, 1872, 1940, 2056, 2196, 2308, 2336, 2372, 2448, 2664, 2696, 2740, 2804, 2848, 2880, 3060, 3200, 3280
OFFSET
1,1
COMMENTS
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.
EXAMPLE
40 is a term since 40 = 2^2 + 6^2 as well as 40^2 + 2 = 1602 = 9^2 + 39^2.
320 is a term since 320 = 8^2 + 16^2 as well as 320^2 + 2 = 102402 = 201^2 + 249^2.
PROG
(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
isok(k) = is1(k) && is1(k^2+2); \\ Michel Marcus, Jul 18 2022
(Python)
from itertools import count, islice
from sympy import factorint
def A355778_gen(startvalue=1): # generator of terms >= startvalue
for n in count(max(startvalue, 1)):
c = False
for p in (f:=factorint(n)):
if (q:= p & 3)==3 and f[p]&1:
break
elif q == 1:
c = True
else:
if c or f.get(2, 0)&1:
c = False
for p in (f:=factorint(n**2+2)):
if (q:= p & 3)==3 and f[p]&1:
break
elif q == 1:
c = True
else:
if c or f.get(2, 0)&1:
yield n
A355778_list = list(islice(A355778_gen(), 30)) # Chai Wah Wu, Sep 14 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Angad Singh, Jul 16 2022
STATUS
approved