A364091 a(n) is the first prime p such that the longest sequence of primes p = p_1, p_2, ... with |p_{k+1} - 2*p_k| = 1 has length n.
13, 7, 11, 5, 3, 2, 16651, 15514861, 85864769, 26089808579, 665043081119, 554688278429, 758083947856951, 95405042230542329, 69257563144280941
Offset: 1
Examples
a(4) = 5 because 5, 2*5 + 1 = 11, 2*11 + 1 = 23, 2*23 + 1 = 47 is a sequence of primes of length 4 while 2*47 - 1 = 93 and 2*47 + 1 = 95 are not primes, and 5 is the smallest prime that works.
Programs
-
Maple
M:= 10: # for a(1) .. a(N) f:= proc(n) option remember; local x; if n mod 3 = 1 then x:= 2*n-1 else x:= 2*n+1 fi; if isprime(x) then 1 + procname(x) else 1 fi; end proc: f(2):= 6: f(3):= 5: V:= Vector(M): p:= 1: count:= 0: for k from 1 while count < M do p:= nextprime(p); v:= f(p); if v <= M and V[v] = 0 then V[v]:= p; count:= count+1; fi od: convert(V,list);
-
Python
from sympy import isprime, nextprime def A364091(n): if 5 <= n <= 6: return 8-n q = 5 while True: p, c = q, 1 while isprime(p:=(p<<1)+(-1 if p%3==1 else 1)): c += 1 if c > n: break if c == n: return q q = nextprime(q) # Chai Wah Wu, Jul 07 2023
Comments