%I #8 Nov 14 2024 12:11:03
%S 13,9,7,21,7,1,15,1,5,23,5,13,1,3,1,1,3,19,1,1,11,1,7,9,1,19,1,17,7,1,
%T 3,1,1,1,11,1,5,1,1,11,3,5,1,1,15,15,1,1,3,1,5,5,1,5,1,1,1,1,13,1,1,9,
%U 1,5,3,1,3,1,1,1,1,23,1,1,1,1,1,1,1,9,3
%N a(n) is the number of iterations of x -> 2*x - 3 until (# composites reached) = (# primes reached), starting with prime(n+2).
%C For a guide to related sequences, see A377609.
%e Starting with prime(3) = 5, we have 2*5-3 = 7, then 2*7-3 = 11, etc., resulting in a chain 5, 7, 11, 19, 35, 67, 131, 259, 515, 1027, 2051, 4099, 8195, 16387 having 7 primes and 7 composites. Since every initial subchain has fewer composites than primes, a(1) = 14-1 = 13. (For more terms from the mapping x -> 2x-3, see A062709.)
%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[3], 2, -3}]
%t Map[Length[chain[{Prime[#], 2, -3}]] &, Range[3, 100]] - 1
%t (* _Peter J. C. Moses_, Oct 31 2024 *)
%Y Cf. A062709, A377609.
%K nonn
%O 1,1
%A _Clark Kimberling_, Nov 05 2024