%I #27 Dec 06 2017 09:29:28
%S 0,0,2,0,1,2,5,0,5,1,4,2,2,5,3,0,3,5,6,1,0,4,3,2,6,2,24,5,5,3,23,0,6,
%T 3,2,5,6,6,10,1,24,0,7,4,3,3,22,2,6,6,5,2,2,24,23,5,7,5,10,3,4,23,19,
%U 0,6,6,8,3,2,2,21,5,24,6,1,6,5,10,10,1,4,24,23,0,0,7,8,4,9,3,19,3,2,22,19
%N Number of odd primes in sequence obtained in 3x+1 (or Collatz) problem starting at n.
%H Reinhard Zumkeller, <a href="/A055509/b055509.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/CollatzProblem.html">Collatz Problem</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>
%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%F a(n) = A078350(n) - 1 for n > 1.
%F a(A196871(n)) = 0. - _Reinhard Zumkeller_, Oct 08 2011
%F From _Robert Israel_, Dec 05 2017: (Start)
%F If n is odd, a(n) = a(3*n+1) + A010051(n).
%F If n is even, a(n) = a(n/2). (End)
%p g:= proc(n) option remember;
%p local x;
%p x:= 3*n+1;
%p x:= x/2^padic:-ordp(x,2);
%p if isprime(n) then procname(x)+1 else procname(x) fi
%p end proc:
%p g(1):= 0:
%p seq(g(n/2^padic:-ordp(n,2)),n=1..100); # _Robert Israel_, Dec 05 2017
%t Join[{0}, Table[Count[NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &], _?PrimeQ] - 1, {n, 2, 94}]] (* _Jayanta Basu_, Jun 15 2013 *)
%o (Haskell) a055509 n = sum $ map a010051 $ takeWhile (> 2) $ iterate a006370 n -- _Reinhard Zumkeller_, Oct 08 2011
%o (PARI) A078350(n,c=0)={while(1<n>>=valuation(n,2), isprime(n)&&c++; n=n*3+1);c} \\ _M. F. Hasler_, Dec 05 2017
%Y Cf. A055510.
%Y Cf. A006370, A010051.
%K nonn
%O 1,3
%A _G. L. Honaker, Jr._, Jun 30 2000
%E More terms from Larry Reeves (larryr(AT)acm.org), Aug 09 2001