A138752 Number of iterations before prime(n) reaches 7 or 2 under x -> A007918(A138750(x)).
0, 1, 2, 0, 1, 4, 2, 7, 5, 3, 20, 16, 6, 6, 4, 4, 21, 23, 19, 17, 17, 15, 7, 5, 7, 5, 28, 22, 26, 22, 22, 20, 18, 18, 16, 20, 16, 14, 6, 6, 8, 59, 8, 8, 6, 29, 27, 25, 23, 25, 23, 23, 27, 23, 21, 19, 19, 21, 19, 17, 19, 17, 19, 17, 17, 15, 13, 11, 9, 11, 9, 60, 58, 54, 11, 9, 7, 30, 28
Offset: 1
Examples
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.
Links
- Paolo Xausa, Table of n, a(n) for n = 1..10000
- Georges Brougnard, Trajectory of 4499221.
- Index entries for sequences related to 3x+1 (or Collatz) problem
Programs
-
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 *)
-
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)}
Comments