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.

A359396 a(n) is the least k such that k^j+2 is prime for j = 1 to n but not n+1.

Original entry on oeis.org

5, 9, 105, 3, 909, 4995825, 28212939
Offset: 1

Views

Author

Robert Israel, Dec 29 2022

Keywords

Comments

All terms are odd, and all except a(1) = 5 are divisible by 3.
The generalized Bunyakovsky conjecture implies that a(n) exists for all n.
a(8) > 10^10.
a(8) > 10^11. - Lucas A. Brown, Jan 11 2023

Examples

			a(4) = 3 because 3^1 + 2 = 5, 3^2 + 2 = 11, and 3^3 + 2 = 29 and 3^4 + 2 = 83 are prime but 3^5 + 2 = 245 is not.
		

Crossrefs

Cf. A087576.

Programs

  • Maple
    f:= proc(n) local j;
     for j from 1 do
         if not isprime(n^j+2) then return j-1 fi
     od
    end proc:
    V:= Vector(7): V[1]:= 5: count:= 1:
    for k from 3 by 6 while count < 7 do
     v:= f(k);
     if v > 0 and V[v] = 0 then V[v]:= k; count:= count+1 fi
    od:
    convert(V,list);
  • Python
    from sympy import isprime
    from itertools import count, islice
    def f(k):
        j = 1
        while isprime(k**j + 2): j += 1
        return j-1
    def agen():
        adict, n = dict(), 1
        for k in count(2):
            v = f(k)
            if v not in adict: adict[v] = k
            while n in adict: yield adict[n]; n += 1
    print(list(islice(agen(), 5))) # Michael S. Branicky, Jan 09 2023