OFFSET
4,1
COMMENTS
It is conjectured that every starting n reaches 2 eventually.
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).
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.
EXAMPLE
For n=4 the trajectory is 4 -> 6 -> 9 -> 13 -> 2 (row 4 of A368196) which has a(4) = 5 terms.
PROG
(PARI) f(n) = if (isprime(n), n - precprime(n-1), n + primepi(n)); \\ A368241
a(n) = my(k=1); while ((n = f(n)) != 2, k++); k+1; \\ Michel Marcus, Jan 03 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Hendrik Kuipers, Jan 03 2024
STATUS
approved