The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A255309 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. 3
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,5
LINKS
FORMULA
a(n) = 1 + a(log_2(n)) if n is a power of 2 except 1, 0 otherwise.
PROG
(PARI) nbi(n) = {my(nb = 0); if ((ispower(n, , &m) && (m==2)) || (n==2), return(nbi(valuation(n, 2))+1); ); nb; }
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
(PARI) A255309(n) = { my(k=0); while((n>1)&&!bitand(n, n-1), n = valuation(n, 2); k++); (k); }; \\ Antti Karttunen, Sep 30 2018
CROSSREFS
Cf. A000079 (2^n), A007814 (2-adic valuation of n), A209229, A255308.
Sequence in context: A072325 A294929 A076948 * A335446 A335460 A367077
KEYWORD
nonn,easy
AUTHOR
Paul Boddington, Feb 20 2015
EXTENSIONS
Extended up to a(128) by Antti Karttunen, Sep 30 2018
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 15 04:00 EDT 2024. Contains 372536 sequences. (Running on oeis4.)