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.
%I A263879 #39 Jul 07 2023 16:03:16 %S A263879 6,5,4,2,3,1,1,3,2,2,2,2,3,1,1,2,1,1,1,1,1,3,2,6,2,1,1,1,1,2,1,2,1,2, %T A263879 1,1,2,1,1,2,5,1,2,1,1,2,2,1,1,2,2,2,1,2,1,1,1,2,1,2,1,2,2,1,1,1,3,2, %U A263879 1,1,1,4,2,1,2,1,1,1,1,1,2,1,2,1,3,2,1,1,1,1,1,1,1,2,3,1,4,1,1,1 %N A263879 Length k of the longest chain of primes p_1, p_2, ..., p_k such that p_1 is the n-th prime and p_{i+1} equals 2*p_i + 1 or 2*p_i - 1 for all i < k, the +/- sign depending on i. %C A263879 If the +/- signs are all + or all -, then p_1, p_2, ..., p_k is a Cunningham chain of the first or second kind, respectively. %C A263879 If p_1 > 3, then the +/- signs must be all + or all -, because if e = +1 or -1, then one of p, 2*p + e, 2*(2*p + e) - e is divisible by 3; see Löh (1989), p. 751. %C A263879 Cunningham chains of the first and second kinds of length > 1 cannot begin with the same prime p > 3, because one of the numbers p, 2*p-1, 2*p+1 is divisible by 3. %D A263879 R. K. Guy, Unsolved Problems in Number Theory, A7. %H A263879 Robert Israel, <a href="/A263879/b263879.txt">Table of n, a(n) for n = 1..10000</a> %H A263879 G. Löh, <a href="http://www.jstor.org/stable/2008735">Long chains of nearly doubled primes</a>, Math. Comp., 53 (1989), 751-759. %H A263879 Wikipedia, <a href="https://en.wikipedia.org/wiki/Cunningham_chain">Cunningham chain</a> %F A263879 a(n) = max(A181697(n), A181715(n)) for n > 2. %F A263879 a(n) < prime(n) for n > 2; see Löh (1989), p. 751. %e A263879 2, 3, 5, 11, 23, 47 is the longest such chain of primes starting with 2. Their indices are 1, 2, 3, 5, 9, 15, respectively, so a(1) = 6, a(2) = 5, a(3) = 4, a(5) = 3, a(9) = 2, and a(15) = 1. %p A263879 f:= proc(n) option remember; local x; %p A263879 if n mod 3 = 1 then x:= 2*n-1 else x:= 2*n+1 fi; %p A263879 if isprime(x) then 1 + procname(x) else 1 fi; %p A263879 end proc: %p A263879 f(2):= 6: f(3):= 5: %p A263879 map(f, [seq(ithprime(i),i=1..100)]); # _Robert Israel_, Jul 04 2023 %t A263879 A263879 = Join[{6, 5}, %t A263879 Table[p = Prime[n]; cnt = 1; %t A263879 While[PrimeQ[2*p + 1] || PrimeQ[2*p - 1], %t A263879 cnt++ && If[PrimeQ[2*p + 1], p = 2*p + 1, p = 2*p - 1 ]]; %t A263879 cnt, {n, 3, 100}]] %o A263879 (Python) %o A263879 from sympy import prime, isprime %o A263879 def A263879(n): %o A263879 if n <= 2: return 7-n %o A263879 p, c = prime(n), 1 %o A263879 while isprime(p:=(p<<1)+(-1 if p%3==1 else 1)): %o A263879 c += 1 %o A263879 return c # _Chai Wah Wu_, Jul 07 2023 %Y A263879 Cf. A005384, A005602, A181697, A181715. %K A263879 nonn %O A263879 1,1 %A A263879 _Jonathan Sondow_, Oct 28 2015