Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #24 Jun 13 2022 10:55:20
%S 0,0,1,0,2,0,0,0,1,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
%T 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
%U 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
%N Number of times log_2 can be applied to n until the result is either 1 or not a power of 2. Here log_2 means the base-2 logarithm.
%H Antti Karttunen, <a href="/A255309/b255309.txt">Table of n, a(n) for n = 0..65537</a>
%F a(n) = 1 + a(log_2(n)) if n is a power of 2 except 1, 0 otherwise.
%o (PARI) nbi(n) = {my(nb = 0); if ((ispower(n, ,&m) && (m==2)) || (n==2), return(nbi(valuation(n, 2))+1);); nb;}
%o a(n) = { my(nb = 0); if ((ispower(n, ,&m) && (m==2)) || (n==2), return(nbi(valuation(n, 2))+1);); nb;} \\ _Michel Marcus_, Mar 11 2015; corrected Jun 13 2022
%o (PARI) A255309(n) = { my(k=0); while((n>1)&&!bitand(n,n-1),n = valuation(n,2); k++); (k); }; \\ _Antti Karttunen_, Sep 30 2018
%Y Cf. A000079 (2^n), A007814 (2-adic valuation of n), A209229, A255308.
%K nonn,easy
%O 0,5
%A _Paul Boddington_, Feb 20 2015
%E Extended up to a(128) by _Antti Karttunen_, Sep 30 2018