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.

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.

This page as a plain text file.
%I A364091 #14 Jul 07 2023 18:58:29
%S A364091 13,7,11,5,3,2,16651,15514861,85864769,26089808579,665043081119,
%T A364091 554688278429,758083947856951,95405042230542329,69257563144280941
%N 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.
%C A364091 a(n) = A000040(k) where A263879(k) = n is the first appearance of n in A263879.
%F A364091 a(n) = min(A005602(n), A005603(n)) for n >= 7.
%e A364091 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.
%p A364091 M:= 10: # for a(1) .. a(N)
%p A364091 f:= proc(n) option remember; local x;
%p A364091   if n mod 3 = 1 then x:= 2*n-1 else x:= 2*n+1 fi;
%p A364091   if isprime(x) then 1 + procname(x) else 1 fi;
%p A364091 end proc:
%p A364091 f(2):= 6: f(3):= 5:
%p A364091 V:= Vector(M):
%p A364091 p:= 1: count:= 0:
%p A364091 for k from 1 while count < M do
%p A364091   p:= nextprime(p);
%p A364091   v:= f(p);
%p A364091   if v <= M and V[v] = 0 then V[v]:= p; count:= count+1; fi
%p A364091 od:
%p A364091 convert(V,list);
%o A364091 (Python)
%o A364091 from sympy import isprime, nextprime
%o A364091 def A364091(n):
%o A364091     if 5 <= n <= 6: return 8-n
%o A364091     q = 5
%o A364091     while True:
%o A364091         p, c = q, 1
%o A364091         while isprime(p:=(p<<1)+(-1 if p%3==1 else 1)):
%o A364091             c += 1
%o A364091             if c > n:
%o A364091                 break
%o A364091         if c == n:
%o A364091             return q
%o A364091         q = nextprime(q) # _Chai Wah Wu_, Jul 07 2023
%Y A364091 Cf. A000040, A263879.
%K A364091 nonn,more
%O A364091 1,1
%A A364091 _Robert Israel_, Jul 04 2023