cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A355778 #21 Sep 15 2022 02:17:29
%S A355778 40,68,72,104,148,180,320,392,468,544,612,648,720,788,832,900,936,968,
%T A355778 1040,1044,1156,1192,1256,1300,1332,1508,1732,1796,1800,1832,1872,
%U A355778 1940,2056,2196,2308,2336,2372,2448,2664,2696,2740,2804,2848,2880,3060,3200,3280
%N A355778 Numbers k such that both k and k^2 + 2 can be written as the sum of two nonzero squares.
%C A355778 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 A355778 40 is a term since 40 = 2^2 + 6^2 as well as 40^2 + 2 = 1602 = 9^2 + 39^2.
%e A355778 320 is a term since 320 = 8^2 + 16^2 as well as 320^2 + 2 = 102402 = 201^2 + 249^2.
%o A355778 (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 A355778 isok(k) = is1(k) && is1(k^2+2); \\ _Michel Marcus_, Jul 18 2022
%o A355778 (Python)
%o A355778 from itertools import count, islice
%o A355778 from sympy import factorint
%o A355778 def A355778_gen(startvalue=1): # generator of terms >= startvalue
%o A355778     for n in count(max(startvalue, 1)):
%o A355778         c = False
%o A355778         for p in (f:=factorint(n)):
%o A355778             if (q:= p & 3)==3 and f[p]&1:
%o A355778                 break
%o A355778             elif q == 1:
%o A355778                 c = True
%o A355778         else:
%o A355778             if c or f.get(2, 0)&1:
%o A355778                 c = False
%o A355778                 for p in (f:=factorint(n**2+2)):
%o A355778                     if (q:= p & 3)==3 and f[p]&1:
%o A355778                         break
%o A355778                     elif q == 1:
%o A355778                         c = True
%o A355778                 else:
%o A355778                     if c or f.get(2, 0)&1:
%o A355778                         yield n
%o A355778 A355778_list = list(islice(A355778_gen(),30)) # _Chai Wah Wu_, Sep 14 2022
%Y A355778 Cf. A000290, A000404, A000415.
%K A355778 nonn
%O A355778 1,1
%A A355778 _Angad Singh_, Jul 16 2022