cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A285099 a(n) is the zero-based index of the second least significant 1-bit in the base-2 representation of n, or 0 if there are fewer than two 1-bits in n.

This page as a plain text file.
%I A285099 #22 May 06 2020 13:24:19
%S A285099 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,
%T A285099 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,
%U A285099 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
%N A285099 a(n) is the zero-based index of the second least significant 1-bit in the base-2 representation of n, or 0 if there are fewer than two 1-bits in n.
%H A285099 Antti Karttunen, <a href="/A285099/b285099.txt">Table of n, a(n) for n = 0..8192</a>
%H A285099 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A285099 If A000120(n) < 2, a(n) = 0, otherwise a(n) = A007814(A129760(n)) = A007814(n AND (n-1)). [Where AND is bitwise-and, A004198].
%F A285099 From _Jeffrey Shallit_, Apr 19 2020: (Start)
%F A285099 This is a 2-regular sequence, satisfying the identities
%F A285099 a(4n) = -a(n) + a(2n),
%F A285099 a(4n+2) = a(4n+1),
%F A285099 a(8n+1) = -a(2n+1) + 2a(4n+1),
%F A285099 a(8n+3) = a(4n+3),
%F A285099 a(8n+5) = 2a(4n+3),
%F A285099 a(8n+7) = a(4n+3). (End)
%e A285099 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.
%e A285099 For n = 4, "100" in binary, there is just one 1-bit present, thus a(4) = 0.
%e A285099 For n = 5, "101" in binary, the second 1-bit from the right is at position 2, thus a(5) = 2.
%e A285099 For n = 25, "11001" in binary, the second 1-bit from the right is at position 3, thus a(25) = 3.
%t A285099 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 *)
%o A285099 (Scheme) (define (A285099 n) (if (<= (A000120 n) 1) 0 (A007814 (A004198bi n (- n 1))))) ;; A004198bi implements bitwise-and.
%o A285099 (Python)
%o A285099 import math
%o A285099 def a007814(n): return int(math.log(n - (n & n - 1), 2))
%o A285099 def a(n): return 0 if bin(n)[2:].count("1") < 2 else a007814(n & (n - 1)) # _Indranil Ghosh_, Apr 20 2017
%Y A285099 Cf. A000120, A004198, A007814, A129760, A285097.
%K A285099 nonn,base
%O A285099 0,6
%A A285099 _Antti Karttunen_, Apr 19 2017