%I #47 Mar 20 2023 05:30:48
%S 1,1,1,2,2,1,1,3,3,1,1,2,2,1,1,4,4,1,1,2,2,1,1,3,3,1,1,2,2,1,1,5,5,1,
%T 1,2,2,1,1,3,3,1,1,2,2,1,1,4,4,1,1,2,2,1,1,3,3,1,1,2,2,1,1,6,6,1,1,2,
%U 2,1,1,3,3,1,1,2,2,1,1,4,4,1,1,2,2,1,1,3,3,1,1,2,2,1,1,5,5,1,1,2,2,1,1,3,3
%N Number of trailing equal digits in binary representation of n.
%C a(even) = number of trailing binary zeros;
%C a(odd) = number of trailing binary ones.
%C For n>0, power of 2 associated with n^2 + n, e.g. n=4 gives 20, so a(4)=2. - _Jon Perry_, Sep 12 2014
%H James Spahlinger, <a href="/A136480/b136480.txt">Table of n, a(n) for n = 0..10000</a>
%H Francis Laclé, <a href="https://hal.archives-ouvertes.fr/hal-03201180v2">2-adic parity explorations of the 3n+ 1 problem</a>, hal-03201180v2 [cs.DM], 2021.
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F a(n) = A050603(n-1) for n>0;
%F a(2*n + n mod 2) = a(n) + 1.
%F For n>0: a(n) = A007814(n + n mod 2).
%F Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=0..m} a(k) = 2. - _Amiram Eldar_, Sep 15 2022
%F a(n) = A007814(A002378(n)), n>0. - _R. J. Mathar_, Mar 20 2023
%p A136480 := proc(n)
%p if n = 0 then
%p 1;
%p else
%p A007814(n*(n+1)) ;
%p end if;
%p end proc:
%p seq( A136480(n),n=0..80) ; # _R. J. Mathar_, Mar 20 2023
%t Length[Last[Split[IntegerDigits[#,2]]]]&/@Range[0,140] (* _Harvey P. Dale_, Mar 31 2011 *)
%o (PARI) a(n)=if (n, valuation(n+n%2,2), 1) \\ _Charles R Greathouse IV_, Oct 14 2013
%o (Haskell)
%o a136480 0 = 1
%o a136480 n = a007814 $ n + mod n 2 -- _Reinhard Zumkeller_, Jul 22 2014
%o (JavaScript)
%o for (n=1;n<120;n++) {
%o m=n*n+n;
%o c=0;
%o while (m%2==0) {m/=2;c++;}
%o document.write(c+", ");
%o } // _Jon Perry_, Sep 12 2014
%o (Python)
%o def A136480(n): return (~(m:=n+(n&1))& m-1).bit_length() # _Chai Wah Wu_, Jul 08 2022
%Y Cf. A007814, A050603, A094267, A163575, A001511, A039963 (parity).
%K nonn,base,easy
%O 0,4
%A _Reinhard Zumkeller_, Dec 31 2007