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.

Showing 1-2 of 2 results.

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.

Original entry on oeis.org

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
Offset: 0

Views

Author

Antti Karttunen, Apr 19 2017

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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
  • Scheme
    (define (A285099 n) (if (<= (A000120 n) 1) 0 (A007814 (A004198bi n (- n 1))))) ;; A004198bi implements bitwise-and.
    

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].
From Jeffrey Shallit, Apr 19 2020: (Start)
This is a 2-regular sequence, satisfying the identities
a(4n) = -a(n) + a(2n),
a(4n+2) = a(4n+1),
a(8n+1) = -a(2n+1) + 2a(4n+1),
a(8n+3) = a(4n+3),
a(8n+5) = 2a(4n+3),
a(8n+7) = a(4n+3). (End)

A366370 Square array A(n,k) giving the length of the least significant run of 0-bits in binary expansion of A000225(n)^k, or 0 if A000225(n)^k is a binary repunit.

Original entry on oeis.org

0, 0, 0, 0, 2, 0, 0, 1, 3, 0, 0, 3, 1, 4, 0, 0, 2, 4, 1, 5, 0, 0, 2, 2, 5, 1, 6, 0, 0, 1, 3, 2, 6, 1, 7, 0, 0, 4, 1, 4, 2, 7, 1, 8, 0, 0, 3, 5, 1, 5, 2, 8, 1, 9, 0, 0, 2, 3, 6, 1, 6, 2, 9, 1, 10, 0, 0, 1, 3, 3, 7, 1, 7, 2, 10, 1, 11, 0, 0, 3, 1, 4, 3, 8, 1, 8, 2, 11, 1, 12, 0, 0, 2, 4, 1, 5, 3, 9, 1, 9, 2, 12, 1, 13, 0
Offset: 1

Views

Author

Antti Karttunen, Oct 14 2023

Keywords

Examples

			The top left corner of the square array:
  n\k| 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17
-----+-------------------------------------------------------------------
   1 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   2 | 0,  2,  1,  3,  2,  2,  1,  4,  3,  2,  1,  3,  2,  2,  1,  5,  4,
   3 | 0,  3,  1,  4,  2,  3,  1,  5,  3,  3,  1,  4,  2,  3,  1,  6,  4,
   4 | 0,  4,  1,  5,  2,  4,  1,  6,  3,  4,  1,  5,  2,  4,  1,  7,  4,
   5 | 0,  5,  1,  6,  2,  5,  1,  7,  3,  5,  1,  6,  2,  5,  1,  8,  4,
   6 | 0,  6,  1,  7,  2,  6,  1,  8,  3,  6,  1,  7,  2,  6,  1,  9,  4,
   7 | 0,  7,  1,  8,  2,  7,  1,  9,  3,  7,  1,  8,  2,  7,  1, 10,  4,
   8 | 0,  8,  1,  9,  2,  8,  1, 10,  3,  8,  1,  9,  2,  8,  1, 11,  4,
   9 | 0,  9,  1, 10,  2,  9,  1, 11,  3,  9,  1, 10,  2,  9,  1, 12,  4,
  10 | 0, 10,  1, 11,  2, 10,  1, 12,  3, 10,  1, 11,  2, 10,  1, 13,  4,
  11 | 0, 11,  1, 12,  2, 11,  1, 13,  3, 11,  1, 12,  2, 11,  1, 14,  4,
  12 | 0, 12,  1, 13,  2, 12,  1, 14,  3, 12,  1, 13,  2, 12,  1, 15,  4,
  13 | 0, 13,  1, 14,  2, 13,  1, 15,  3, 13,  1, 14,  2, 13,  1, 16,  4,
  14 | 0, 14,  1, 15,  2, 14,  1, 16,  3, 14,  1, 15,  2, 14,  1, 17,  4,
  15 | 0, 15,  1, 16,  2, 15,  1, 17,  3, 15,  1, 16,  2, 15,  1, 18,  4,
  16 | 0, 16,  1, 17,  2, 16,  1, 18,  3, 16,  1, 17,  2, 16,  1, 19,  4,
  17 | 0, 17,  1, 18,  2, 17,  1, 19,  3, 17,  1, 18,  2, 17,  1, 20,  4,
etc.
A000225(4)^4 = ((2^4)-1)^4 = 50625 and A007088(50625) = "1100010111000001", where the rightmost run of 0-bits has length 5, therefore A(4,4) = 5.
A000225(3)^5 = ((2^3)-1)^5 = 16807 and A007088(16807) = "100000110100111", where the rightmost run of 0-bits has length 2, therefore A(3,5) = 2.
A000225(5)^3 = ((2^5)-1)^3 = 29791 and A007088(29791) = "111010001011111", where the rightmost run of 0-bits is a singleton, therefore A(5,3) = 1.
		

Crossrefs

Programs

  • Mathematica
    A285097[n_]:=If[DigitCount[n,2,1]<2,0,IntegerExponent[BitAnd[n-1,n],2]-IntegerExponent[n,2]];A366370[n_,k_]:=A285097[1+(2^n-1)^k];
    Table[A366370[k,n-k+1],{n,20},{k,n}] (* Paolo Xausa, Dec 02 2023 *)
  • PARI
    up_to = 105;
    A285097(n) = if(!n || !bitand(n,n-1), 0, valuation((n>>valuation(n,2))-1, 2));
    A366370sq(n,k) = A285097(1+(((2^n)-1)^k));
    \\ Or more directly as:
    A366370sq(n,k) = if(1==n||1==k, 0, if(!(k%2), n, 1)+valuation(k>>1,2));
    A366370list(up_to) = { my(v = vector(up_to), i=0); for(a=1,oo, for(col=1,a, i++; if(i > up_to, return(v)); v[i] = A366370sq(col,(a-(col-1))))); (v); };
    v366370 = A366370list(up_to);
    A366370(n) = v366370[n];

Formula

A(n,k) = A285097(1+(A000225(n)^k)).
For all n >= 2, k >= 2, A(n,2k) = n+A007814(k), A(n,2k+1) = 1+A007814(k).
Showing 1-2 of 2 results.