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.
%I A353089 #58 Jul 11 2022 08:37:18 %S A353089 4,93,532,5607,31932,31433,604122,3851523,39175298,378044079, %T A353089 367876650,383204683,22076314482 %N A353089 Least number which differs from both of its prime neighbors by n^2, and -1 if no such number exists. %C A353089 a(12) < 1294268635 is the first term where the first formula is a strict inequality. - _Michael S. Branicky_, Apr 22 2022 %F A353089 a(n) <= A000040(A038664(n^2)) + n^2. - _Alois P. Heinz_, Apr 22 2022 %F A353089 a(n) <= A000230(n^2) + n^2. - _David A. Corneth_, May 02 2022 %F A353089 a(n) = A282690(n^2). - _Michel Marcus_, Jul 10 2022 %e A353089 a(1) = 4, because 3 and 5 are the prime neighbors of 4, and 5 - 4 = 4 - 3 = 1 = 1^2 and no number less than 4 differs from both of its prime neighbors by 1^2. %e A353089 a(2) = 93, because 97 and 89 are the prime neighbors of 93, and 97 - 93 = 93 - 89 = 4 = 2^2 and no number less than 93 differs from both of its prime neighbors by 2^2. %t A353089 a[n_] := a[n] = Module[{diff, diff2, p, q, r}, %t A353089 {diff, diff2, p} = {n*n, 2*n*n, NextPrime[1 + n^2]}; %t A353089 q = NextPrime[p]; %t A353089 r = NextPrime[q]; %t A353089 While[!(q - p == diff2 || (q - p == diff && r - q == diff)), %t A353089 {p, q, r} = {q, r, NextPrime[r]}]; %t A353089 Return[If[q - p == diff2, Floor[(q + p)/2], q]]]; %t A353089 Table[Print[n, " ", a[n]]; a[n], {n, 1, 10}] (* _Jean-François Alcover_, Jun 07 2022, after _Michael S. Branicky_'s code *) %o A353089 (Python) %o A353089 from sympy import nextprime %o A353089 def a(n): %o A353089 diff, diff2, p = n*n, 2*n*n, nextprime(1+n**2) %o A353089 q = nextprime(p) %o A353089 r = nextprime(q) %o A353089 while not (q-p == diff2 or (q-p == diff and r-q == diff)): %o A353089 p, q, r = q, r, nextprime(r) %o A353089 return (q+p)//2 if q-p == diff2 else q %o A353089 print([a(n) for n in range(1, 9)]) # _Michael S. Branicky_, Apr 22 2022 %o A353089 (PARI) a(n) = my(k=2); while (((nextprime(k+1)-k) != n^2) || ((k-precprime(k-1)) != n^2), k++); k; \\ _Michel Marcus_, Jul 10 2022 %Y A353089 Cf. A000040, A000230, A000290, A038664, A353073, A055380, A282690. %K A353089 nonn,more %O A353089 1,1 %A A353089 _Jean-Marc Rebert_, Apr 22 2022 %E A353089 a(13) from _Michael S. Branicky_, Apr 24 2022