%I #17 Jan 31 2024 07:58:04
%S 5,2,4,2,8,3,9,6,7,2,8,7,10,6,9,2,7,6,9,6,17,8,16,8,6,5,8,2,3,16,7,15,
%T 7,5,9,10,7,6,8,2,15,6,14,6,5,10,8,9,6,5,7,7,16,3,14,5,13,2,14,4,9,7,
%U 8,5,5,13,6,6,15,2,13,11,10,12,28,5,13,3,8,6,7,15,3,4,12,5
%N Number of terms in the trajectory from n to 2 of the map x -> A368241(x), or -1 if n never reaches 2.
%C It is conjectured that every starting n reaches 2 eventually.
%C A368241(x) decreases to the prime gap x-prevprime(x) when x is prime, or increases to x+primepi(x) otherwise, and will reach 2 when x is the greater of a twin prime pair (A006512, preceding prime gap 2).
%C Prime gaps and x+primepi(x) may become large, but if the twin prime conjecture is true then there would be large twin primes they might reach too.
%e For n=4 the trajectory is 4 -> 6 -> 9 -> 13 -> 2 (row 4 of A368196) which has a(4) = 5 terms.
%o (PARI) f(n) = if (isprime(n), n - precprime(n-1), n + primepi(n)); \\ A368241
%o a(n) = my(k=1); while ((n = f(n)) != 2, k++); k+1; \\ _Michel Marcus_, Jan 03 2024
%Y Cf. A368241.
%Y Cf. A000720, A005171, A010051, A006512.
%K nonn
%O 4,1
%A _Hendrik Kuipers_, Jan 03 2024