%I #82 Nov 17 2022 05:27:16
%S 0,0,1,0,1,1,2,0,1,1,2,1,2,2,3,0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,0,1,1,
%T 2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,0,1,1,2,1,
%U 2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3
%N a(n) = A000120(n+1) - 1 = wt(n+1) - 1.
%C Highest power of 2 dividing n-th Catalan number (A000108).
%C a(n) = 0 iff n = 2^k - 1, k=0,1,...
%C Appears to be number of binary left-rotations (iterations of A006257) to reach fixed point of form 2^k-1. Right-rotation analog is A063250. This would imply that for n >= 0, a(n)=f(n), recursively defined to be 0 for n=0, otherwise as f( ( (1-n)(1-p)(1-s) - (1-n-p-s) ) / 2) + p (s+1) / 2, where p = n mod 2 and s = - signum(n) (f(n<0) is A000120(-n)). - _Marc LeBrun_, Jul 11 2001
%C Let f(0) = 01, f(1) = 12, f(2) = 23, f(3) = 34, f(4) = 45, etc. Sequence gives concatenation of 0, f(0), f(f(0)), f(f(f(0))), ... Also f(f(...f(0)...)) converges to A000120. - _Philippe Deléham_, Aug 14 2003
%C C(n, k) is the number of occurrence of k in the n-th group of terms in this sequence read by rows: {0}; {0, 1}; {0, 1, 1, 2}; {0, 1, 1, 2, 1, 2, 2, 3}; {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; ... - _Philippe Deléham_, Jan 01 2004
%C Highest power of 2 dividing binomial(n,floor(n/2)). - _Benoit Cloitre_, Oct 20 2003
%C 2^a(n) are numerators in the Maclaurin series for (sin x)^2. - _Jacob A. Siehler_, Nov 11 2009
%C Conjecture: a(n) is the sum of digits of the n-th word in A076478, for n >= 1; has been confirmed for n up to 20000. - _Clark Kimberling_, Jul 14 2021
%H R. Alter and K. K. Kubota, <a href="http://dx.doi.org/10.1016/0097-3165(73)90072-1">Prime and Prime Power Divisibility of Catalan Numbers</a>, J. Comb. Th. A 15 (1973) pp. 243-256.
%H E. Deutsch and B. E. Sagan, <a href="https://arxiv.org/abs/math/0407326">Congruences for Catalan and Motzkin numbers and related sequences</a>, arXiv:math/0407326 [math.CO], 2004; J. Num. Theory 117 (2006), 191-215.
%F Writing n as 2^m+k with -1 <= k < 2^m-1, then a(n) = A000120(k+1). - _Henry Bottomley_, Mar 28 2000
%F a(n) = k if 2^k divides A000108(n) but 2^(k+1) does not divide A000108(n).
%F a(2*n) = a(n-1)+1, a(2*n+1) = a(n). - _Vladeta Jovovic_, Oct 10 2002
%F G.f.: (1/(x-x^2)) * (x^2/(1-x) - Sum_{k>=1} x^(2^k)/(1-x^(2^k))). - _Ralf Stephan_, Apr 13 2002
%F a(n) = A000120(A129760(n+1)). - _Reinhard Zumkeller_, Jun 30 2010
%F a(n+k) = A240857(n,k), 0 <= k <= n; in particular: a(n) = A240857(n,0). - _Reinhard Zumkeller_, Apr 14 2014
%F a(n) = (n+1)*2 - A101925(n+1). - _Gleb Ivanov_, Jan 12 2022
%e From _Omar E. Pol_, Mar 08 2011: (Start)
%e Sequence can be written in the following form (irregular triangle):
%e 0,
%e 0,1,
%e 0,1,1,2,
%e 0,1,1,2,1,2,2,3,
%e 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
%e 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
%e ...
%e Row sums are A001787.
%e (End)
%p A048881 := proc(n)
%p A000120(n+1)-1 ;
%p end proc:
%p seq(A048881(n),n=0..200) ; # _R. J. Mathar_, Mar 12 2018
%t a[n_] := IntegerExponent[ CatalanNumber[n], 2]; Table[a[n], {n, 0, 104}] (* _Jean-François Alcover_, Jun 21 2013 *)
%o (PARI) { a(n) = if( n<0, 0, n++; n /= 2^valuation(n,2); subst( Pol( binary( n ) ), x, 1) - 1 ) } /* _Michael Somos_, Aug 23 2007 */
%o (PARI) {a(n) = if( n<0, 0, valuation( (2*n)! / n! / (n+1)!, 2 ) ) } /* _Michael Somos_, Aug 23 2007 */
%o (PARI) a(n) = hammingweight(n+1) - 1; \\ _Michel Marcus_, Nov 15 2022
%o (Haskell)
%o a048881 n = a048881_list !! n
%o a048881_list = c [0] where c (x:xs) = x : c (xs ++ [x,x+1])
%o -- _Reinhard Zumkeller_, Mar 07 2011
%o (Python 3.10+)
%o def A048881(n): return (n+1).bit_count()-1 # _Chai Wah Wu_, Nov 15 2022
%Y Cf. A000120, A006257, A007318, A063250.
%Y First differences of A078903.
%K nonn,easy
%O 0,7
%A _Wolfdieter Lang_
%E Entry revised by _N. J. A. Sloane_, Jun 07 2009