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.

This page as a plain text file.
%I A381041 #33 Jun 19 2025 13:28:03
%S A381041 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,
%T A381041 379,61,109,433,3,79,127,79,67,139,127,229,7,109,271,313,3,151,7,103,
%U A381041 67,283,421,67,43,373,97,97,97,19,61,3,157,331,127,37,139,439,421
%N A381041 Smallest prime p such that 3^n + p + 1 is prime.
%H A381041 Robert Israel, <a href="/A381041/b381041.txt">Table of n, a(n) for n = 0..2000</a>
%F A381041 a(n) = A020483(A007051(n)). - _Robert Israel_, Jun 19 2025
%e A381041 a(0) = 3, since 3 + (3^0+1) = 5 is prime and 2 + (3^0+1) = 4 is not.
%e A381041 a(1) = 3, since 3 + (3^1+1) = 7 is prime and 2 + (3^1+1) = 6 is not.
%p A381041 f:= proc(n) local t,p;
%p A381041  p:= 1: t:= 3^n+1;
%p A381041  do
%p A381041    p:= nextprime(p);
%p A381041    if isprime(p+t) then return p fi
%p A381041  od;
%p A381041 end proc:
%p A381041 map(f, [$0..100]); # _Robert Israel_, Jun 19 2025
%t A381041 a[n_]:=Module[{p=2},While[!PrimeQ[p+3^n+1], p=NextPrime[p]]; p]; Array[a,65,0] (* _Stefano Spezia_, Apr 25 2025 *)
%o A381041 (Python)
%o A381041 from sympy import isprime, nextprime
%o A381041 def a(n):
%o A381041     p, b = 2, 3**n+1
%o A381041     while not isprime(p+b):
%o A381041         p = nextprime(p)
%o A381041     return p
%o A381041 print([a(n) for n in range(65)]) # _Michael S. Branicky_, Apr 23 2025
%o A381041 (Python)
%o A381041 from sympy import nextprime, isprime
%o A381041 def A381041(n):
%o A381041     p = 3**n+1
%o A381041     q = nextprime(p)
%o A381041     while not isprime(q-p):
%o A381041         q = nextprime(q)
%o A381041     return q-p # _Chai Wah Wu_, May 01 2025
%o A381041 (PARI) a(n) = my(p=2, x=3^n+1); while (!isprime(p+x), p=nextprime(p+1)); p; \\ _Michel Marcus_, Apr 24 2025
%Y A381041 Cf. A007051, A020483, A056206, A056208, A057673.
%K A381041 nonn
%O A381041 0,1
%A A381041 _James S. DeArmon_, Apr 20 2025
%E A381041 More terms from _Michael S. Branicky_, Apr 23 2025