%I #7 Nov 17 2020 21:06:30
%S 5,2,1,1,1,2,1,1,3,1,2,1,1,1,1,1,6,1,1,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,
%T 1,1,1,1,1,2,2,1,2,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,
%U 1,1,2,1,1,1,1,1,2,1,4,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,2,1,1,2,2,1,1,1,2,1
%N Lengths of Cunningham chains of the first kind that are sorted by first prime in the chain.
%C Row lengths of A075712.
%H Michael De Vlieger, <a href="/A338945/b338945.txt">Table of n, a(n) for n = 1..10000</a>
%H Chris K. Caldwell, <a href="https://primes.utm.edu/glossary/page.php?sort=CunninghamChain">Cunningham Chain</a> (PrimePages, Prime Glossary).
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Cunningham_chain">Cunningham chain</a>.
%e We begin with the smallest prime 2. Since 2(5) + 1 = 11 is prime, further, 2(11) + 1 = 23, 2(23) + 1 = 47 are prime but 2(47) + 1 = 95 is not, we have the complete chain {2, 5, 11, 23, 47} of length 5, thus a(1) = 5.
%e We resume with 3, since 3 has not appeared in any chain generated thus far. Since 2(3) + 1 = 7, but 2(7) + 1 = 15, we have the complete chain {3, 7}, therefore a(2) = 2.
%e Starting from 13, we find 2(13) + 1 = 27, thus we have a singleton chain and have a(3) = 1, etc.
%t Block[{a = {2}, b = {}, j = 0, k, p}, Do[k = Length@ b + 1; If[PrimeQ@ a[[-1]], AppendTo[a, 2 a[[-1]] + 1]; j++, While[! FreeQ[a, Set[p, Prime[k]]], k++]; AppendTo[b, j]; Set[j, 0]; Set[a, Append[a[[1 ;; -2]], p]]], 10^3}; b]
%Y Cf. A075712, A338944, A338946.
%K nonn
%O 1,1
%A _Michael De Vlieger_, Nov 17 2020