OFFSET
1,3
COMMENTS
As explained in A138751, the map x->A007918(A138750(x)) is a natural generalization of the Collatz map to primes.
The only even prime p=2 is the only fixed point of this map, and all odd primes seem to end up in the loop 7 -> 17 -> 11 -> 7, after a number of steps given in the present sequence.
(It might have been more natural to count the steps until a number is reached for the second time. Depending on which number among {2,7,11,17} is reached first, this would increase the value of a(n) by 1,3,2 resp. 1.)
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000
Georges Brougnard, Trajectory of 4499221.
EXAMPLE
a(1)=a(4)=0 since prime(1)=2 and prime(4)=7 are by definition the values at which counting ends.
a(primepi(4499221))=63337 according to G. Brougnard, cf. Link.
MATHEMATICA
A138752[n_]:=Length[NestWhileList[NextPrime[If[Mod[#, 3]==2, #/2, 2#]]&, Prime[n], #!=2&&#!=7&]]-1; Array[A138752, 100] (* Paolo Xausa, Jul 28 2023 *)
PROG
(PARI) A138752(n, c=0) = { if( n==1 & 7==n=prime(n), 0, until( 7==n=nextprime( if( n%3==2, ceil(n/2), 2*n )), c++); c)}
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
M. F. Hasler, Mar 28 2008
STATUS
approved