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
CROSSREFS
KEYWORD
nonn
AUTHOR
Angad Singh, Jul 16 2022
STATUS
approved