login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A285099 a(n) = zero-based index of the second least significant 1-bit in base-2 representation of n, 0 if there are less than two 1-bits in n. 5
0, 0, 0, 1, 0, 2, 2, 1, 0, 3, 3, 1, 3, 2, 2, 1, 0, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, 0, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, 0, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1, 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, 5, 4, 4, 1, 4, 2, 2, 1, 4 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,6

LINKS

Antti Karttunen, Table of n, a(n) for n = 0..8192

Index entries for sequences related to binary expansion of n

FORMULA

If A000120(n) < 2, a(n) = 0, otherwise a(n) = A007814(A129760(n)) = A007814(n AND (n-1)). [Where AND is bitwise-and, A004198].

EXAMPLE

For n = 3, "11" in binary, the second least significant 1-bit (the second 1-bit from the right) is at position 1 (when the rightmost position is position 0), thus a(3) = 1.

For n = 4, "100" in binary, there is just one 1-bit present, thus a(4) = 0.

For n = 5, "101" in binary, the second 1-bit from the right is at position 2, thus a(5) = 2.

For n = 25, "11001" in binary, the second 1-bit from the right is at position 3, thus a(25) = 3.

MATHEMATICA

a007814[n_]:=IntegerExponent[n, 2]; a[n_]:=If[DigitCount[n, 2, 1]<2, 0, a007814[BitAnd[n, n - 1]]]; Table[a[n], {n, 0, 150}] (* Indranil Ghosh, Apr 20 2017 *)

PROG

(Scheme) (define (A285099 n) (if (<= (A000120 n) 1) 0 (A007814 (A004198bi n (- n 1))))) ;; A004198bi implements bitwise-and.

(Python)

import math

def a007814(n): return int(math.log(n - (n & n - 1), 2))

def a(n): return 0 if bin(n)[2:].count("1") < 2 else a007814(n & (n - 1)) # Indranil Ghosh, Apr 20 2017

CROSSREFS

Cf. A000120, A004198, A007814, A129760, A285097.

Sequence in context: A276770 A258291 A146527 * A306754 A063250 A285308

Adjacent sequences:  A285096 A285097 A285098 * A285100 A285101 A285102

KEYWORD

nonn,base

AUTHOR

Antti Karttunen, Apr 19 2017

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 16 23:49 EDT 2019. Contains 325092 sequences. (Running on oeis4.)