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.

A381041 Smallest prime p such that 3^n + p + 1 is prime.

Original entry on oeis.org

3, 3, 3, 3, 7, 7, 3, 19, 7, 3, 3, 19, 79, 7, 7, 43, 67, 139, 127, 103, 7, 97, 3, 31, 31, 13, 379, 61, 109, 433, 3, 79, 127, 79, 67, 139, 127, 229, 7, 109, 271, 313, 3, 151, 7, 103, 67, 283, 421, 67, 43, 373, 97, 97, 97, 19, 61, 3, 157, 331, 127, 37, 139, 439, 421
Offset: 0

Views

Author

James S. DeArmon, Apr 20 2025

Keywords

Examples

			a(0) = 3, since 3 + (3^0+1) = 5 is prime and 2 + (3^0+1) = 4 is not.
a(1) = 3, since 3 + (3^1+1) = 7 is prime and 2 + (3^1+1) = 6 is not.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local t,p;
     p:= 1: t:= 3^n+1;
     do
       p:= nextprime(p);
       if isprime(p+t) then return p fi
     od;
    end proc:
    map(f, [$0..100]); # Robert Israel, Jun 19 2025
  • Mathematica
    a[n_]:=Module[{p=2},While[!PrimeQ[p+3^n+1], p=NextPrime[p]]; p]; Array[a,65,0] (* Stefano Spezia, Apr 25 2025 *)
  • PARI
    a(n) = my(p=2, x=3^n+1); while (!isprime(p+x), p=nextprime(p+1)); p; \\ Michel Marcus, Apr 24 2025
  • Python
    from sympy import isprime, nextprime
    def a(n):
        p, b = 2, 3**n+1
        while not isprime(p+b):
            p = nextprime(p)
        return p
    print([a(n) for n in range(65)]) # Michael S. Branicky, Apr 23 2025
    
  • Python
    from sympy import nextprime, isprime
    def A381041(n):
        p = 3**n+1
        q = nextprime(p)
        while not isprime(q-p):
            q = nextprime(q)
        return q-p # Chai Wah Wu, May 01 2025
    

Formula

a(n) = A020483(A007051(n)). - Robert Israel, Jun 19 2025

Extensions

More terms from Michael S. Branicky, Apr 23 2025