%I #97 Sep 10 2024 08:44:22
%S 2,1,4,1,2,1,3,1,2,1,6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5,1,2,1,3,1,2,1,
%T 4,1,2,1,3,1,2,1,8,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5,1,2,1,3,1,2,1,4,1,
%U 2,1,3,1,2,1,6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1
%N a(n) is the 2-adic valuation of 6*n + 4.
%C In Collatz-algorithm if initiated with m=odd value, the first 3x+1 step is followed by a(n) step corresponding to division by 2. Compare to A085058 and A087229. Each 2nd term is either =1 or equals corresponding term of A087229, depending on whether the odd number congruent to 1 or 3 modulo 4.
%C From _K. G. Stier_, Aug 19 2014: (Start)
%C Sequence exhibits a "pseudo" ruler function (A001511) behavior. It is similar to the latter in repeating equal terms m>0 after each 2^m steps. However, the first occurrence of m in the mentioned ruler function is simply at n=log_2(m), while in the given sequence this property develops two distinct (odd and even) strands:
%C First occurrence of
%C m=1 at a(1); m=2 at a(0)
%C m=3 at a(6); m=4 at a(2)
%C m=5 at a(26); m=6 at a(10)
%C m=7 at a(106); m=8 at a(42)
%C m=9 at a(426); m=10 at a(170)
%C ...
%C where values n in the odd strand (1,6,26,106,426,...) equal sequence A020989, and values n in the even strand (0,2,10,42,170,...) equal sequence A020988. (End)
%H Kenny Lau, <a href="/A087230/b087230.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) = A007814(A016957(n)). - _Michel Marcus_, Jan 27 2022
%F Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 2. - _Amiram Eldar_, Sep 10 2024
%e n=85: m = 6*85+4 = 514 and Collatz-iteration goes on by one dividing step, a(85)=1.
%p a:= n-> padic[ordp](6*n+4, 2):
%p seq(a(n), n=0..120); # _Alois P. Heinz_, Mar 16 2021
%t Table[Part[Part[FactorInteger[6*w+4], 1], 2], {w, 0, 100}]
%t Table[IntegerExponent[6*n + 4, 2], {n, 0, 100}] (* _Amiram Eldar_, Jan 27 2022 *)
%o (PARI) forstep(n=0, 1000, 1, m=6*n+4; print1(valuation(m, 2), ", ") ) \\ _K. G. Stier_, Aug 19 2014
%o (Python)
%o n=100; N=3*n+2; val=[1]*(N+1); exp=2
%o while exp <= N:
%o for j in range(exp,N+1,exp): val[j] += 1
%o exp *= 2
%o for i in range(n+1): print(i,val[3*i+2])
%o # _Kenny Lau_, Jun 09 2018
%o (Python)
%o def A087230(n): return (~(m:=6*n+4) & m-1).bit_length() # _Chai Wah Wu_, Jul 02 2022
%o (Perl)
%o sub a {
%o my $nv= ((shift() << 1) | 1);
%o my $bp= 1;
%o while (($nv & 1) xor ($nv & 2)) {
%o $nv>>= 1;
%o $bp++;
%o }
%o return $bp;
%o } # _Ruud H.G. van Tol_, Nov 16 2021
%Y Cf. A007814, A016957, A085058, A087229, A020988, A020989, A061547.
%K nonn,easy
%O 0,1
%A _Labos Elemer_, Aug 28 2003
%E a(0) = 2 prepended by _Andrey Zabolotskiy_, Jan 27 2022, based on _Ihar Senkevich_'s contribution