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.

A353089 Least number which differs from both of its prime neighbors by n^2, and -1 if no such number exists.

Original entry on oeis.org

4, 93, 532, 5607, 31932, 31433, 604122, 3851523, 39175298, 378044079, 367876650, 383204683, 22076314482
Offset: 1

Views

Author

Jean-Marc Rebert, Apr 22 2022

Keywords

Comments

a(12) < 1294268635 is the first term where the first formula is a strict inequality. - Michael S. Branicky, Apr 22 2022

Examples

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

Crossrefs

Programs

  • Mathematica
    a[n_] := a[n] = Module[{diff, diff2, p, q, r},
         {diff, diff2, p} = {n*n, 2*n*n, NextPrime[1 + n^2]};
         q = NextPrime[p];
         r = NextPrime[q];
         While[!(q - p == diff2 || (q - p == diff && r - q == diff)),
              {p, q, r} = {q, r, NextPrime[r]}];
         Return[If[q - p == diff2, Floor[(q + p)/2], q]]];
    Table[Print[n, " ", a[n]]; a[n], {n, 1, 10}] (* Jean-François Alcover, Jun 07 2022, after Michael S. Branicky's code *)
  • 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
  • Python
    from sympy import nextprime
    def a(n):
        diff, diff2, p = n*n, 2*n*n, nextprime(1+n**2)
        q = nextprime(p)
        r = nextprime(q)
        while not (q-p == diff2 or (q-p == diff and r-q == diff)):
            p, q, r = q, r, nextprime(r)
        return (q+p)//2 if q-p == diff2 else q
    print([a(n) for n in range(1, 9)]) # Michael S. Branicky, Apr 22 2022
    

Formula

a(n) <= A000040(A038664(n^2)) + n^2. - Alois P. Heinz, Apr 22 2022
a(n) <= A000230(n^2) + n^2. - David A. Corneth, May 02 2022
a(n) = A282690(n^2). - Michel Marcus, Jul 10 2022

Extensions

a(13) from Michael S. Branicky, Apr 24 2022