%I #7 Dec 05 2024 09:26:22
%S 7,9,1,5,13,7,9,13,1,1,5,1,7,1,7,5,7,1,5,7,5,1,1,1,7,5,5,1,1,3,3,1,1,
%T 11,1,1,3,1,3,3,5,1,1,3,1,1,1,1,1,1,1,3,1,1,1,1,7,11,5,1,9,7,1,5,3,1,
%U 1,7,1,5,3,1,1,1,5,3,1,3,1,1,1,5,1,3,1
%N a(n) is the number of iterations of x -> 6*x - 5 until (# composites reached) = (# primes reached), starting with prime(n).
%C For a guide to related sequences, see A377609.
%e Starting with prime(1) = 2, we have 6*2-5 = 7, then 6*7-5 = 37, etc., resulting in a chain 2, 7, 37, 217, 1297, 7777, 46657, 279937 having 4 primes and 4 composites. Since every initial subchain has fewer composites than primes, a(1) = 8-1 = 7. (For more terms from the mapping x -> 6x-5, see A062394.)
%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[1], 6, -5}]
%t Map[Length[chain[{Prime[#], 6, -5}]] &, Range[1, 100]] - 1
%t (* _Peter J. C. Moses_, Oct 31 2024 *)
%Y Cf. A377609, A062394.
%K nonn
%O 1,1
%A _Clark Kimberling_, Nov 20 2024