login
Number of iterations of the Collatz recursion required to reach a prime number.
3

%I #27 Jan 11 2017 11:50:28

%S 2,0,0,1,0,1,0,2,3,1,0,2,0,1,2,3,0,4,0,2,6,1,0,3,3,1,2,2,0,3,0,4,6,1,

%T 2,5,0,1,2,3,0,7,0,2,4,1,0,4,3,4,6,2,0,3,2,3,3,1,0,4,0,1,17,5,6,7,0,2,

%U 5,3,0,6,0,1,2,2,4,3,0,4,3,1,0,8,8,1,2

%N Number of iterations of the Collatz recursion required to reach a prime number.

%C If n is prime then a(n)=0. If n is composite then a(n)=A280929(n). - _Dmitry Kamenetsky_, Jan 11 2017

%H Seiichi Manyama, <a href="/A274472/b274472.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>

%t Table[Length@ NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, ! PrimeQ@ # &] - 1, {n, 120}] (* _Michael De Vlieger_, Jun 26 2016 *)

%o (PARI) a(n) = my(i=0, k=n); while(!ispseudoprime(k), if(k%2==0, k=k/2, k=3*k+1); i++); i

%o for(n=1, 87, print1(a(n), ", ")) \\ _Felix Fröhlich_, Jun 24 2016

%Y Cf. A000040, A006877, A280929.

%K nonn

%O 1,1

%A _Matthew Campbell_, Jun 24 2016

%E More terms from _Felix Fröhlich_, Jun 24 2016