%I #8 Nov 14 2024 12:11:07
%S 25,1,19,1,11,15,1,1,1,1,13,9,3,1,1,21,1,1,1,11,1,7,1,1,1,1,1,11,17,1,
%T 3,1,1,1,1,1,13,1,1,1,5,1,1,1,3,1,3,1,1,1,9,9,1,1,1,15,1,1,1,5,1,1,1,
%U 1,1,1,11,1,1,1,1,3,3,1,3,1,1,1,7,1,1,3
%N a(n) is the number of iterations of x -> 2*x - 5 until (# composites reached) = (# primes reached), starting with prime(n+4).
%C For a guide to related sequences, see A377609.
%e Starting with prime(5) = 11, we have 2*11-5 = 17, then 2*17-5 = 31, etc., resulting in a chain 11, 17, 29, 53, 101, 197, 389, 773, 1541, 3077, 6149, 12293, 24581, 49157, 98309, 196613, 393221, 786437, 1572869, 3145733, 6291461, 12582917, 25165829, 50331653, 100663301, 201326597 having 13 primes and 13 composites. Since every initial subchain has fewer composites than primes, a(1) = 26-1 = 25.
%t chain[{start_, u_, v_}] := If[CoprimeQ[u, v] && start*u + v != start,
%t NestWhile[Append[#, u*Last[#] + v] &, {start}, !
%t Count[#, _?PrimeQ] == Count[#, _?(! PrimeQ[#] &)] &], {}];
%t chain[{Prime[5], 2, -5}]
%t Map[Length[chain[{Prime[#], 2, -5}]] &, Range[5, 100]] - 1
%t (* _Peter J. C. Moses_, Oct 31 2024 *)
%Y Cf. A377609.
%K nonn
%O 1,1
%A _Clark Kimberling_, Nov 05 2024