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.

A213370 a(n) = n AND 2*n, where AND is the bitwise AND operator.

Original entry on oeis.org

0, 0, 0, 2, 0, 0, 4, 6, 0, 0, 0, 2, 8, 8, 12, 14, 0, 0, 0, 2, 0, 0, 4, 6, 16, 16, 16, 18, 24, 24, 28, 30, 0, 0, 0, 2, 0, 0, 4, 6, 0, 0, 0, 2, 8, 8, 12, 14, 32, 32, 32, 34, 32, 32, 36, 38, 48, 48, 48, 50, 56, 56, 60, 62, 0, 0, 0, 2, 0, 0, 4, 6, 0, 0, 0, 2, 8, 8
Offset: 0

Views

Author

Alex Ratushnyak, Jun 14 2012

Keywords

Crossrefs

Cf. A003714: indices of 0's.
Cf. A213540: indices of 2's, indices of 4's divided by 2.

Programs

  • Mathematica
    Table[BitAnd[n, 2n], {n, 0, 63}] (* Alonso del Arte, Jun 19 2012 *)
  • PARI
    a(n) = bitand(n, 2*n); \\ Michel Marcus, Mar 26 2021
  • Python
    for n in range(99):
        print(2*n & n, end=", ")
    

Formula

a(n) = 2 * A048735(n).
a(n) = (1/2)*(A048727(n) XOR A269160(n)) = (n OR 2n) XOR (n XOR 2n). - Antti Karttunen, May 16 2021

A348710 In the binary expansion of n, decrease the length of each run of 1-bits by one.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 0, 0, 0, 1, 0, 0, 2, 3, 8, 4, 4, 5, 12, 6, 14, 15, 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 16, 8, 8, 9, 8, 4, 10, 11, 24, 12, 12, 13, 28, 14, 30, 31, 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 0, 0, 0
Offset: 0

Views

Author

Kevin Ryde, Oct 30 2021

Keywords

Comments

Equivalently, change bits 01 -> 0, including a 0 reckoned above the most significant 1-bit of n so change there.
A single 1-bit run decreases to nothing. The Fibbinary numbers (A003714) are those n with only single 1-bits so that a(n) = 0 iff n is in A003714.
a(n) = 1 iff n is in A213540 since those values end with bits 011 (which become 01) and otherwise have only single 1-bits, as do the Fibbinary numbers.
Decreasing each run is the inverse of the increase A175048 so that a(A175048(k)) = k. This n = A175048(k) is the smallest n with a(n) = k and then other occurrences of k are by inserting single 1-bits into this n, including anywhere above the most significant bit.

Examples

			n    = 14551 = binary 111 000 11 0 1 0 111
a(n) =   787 = binary  11 000  1 0   0  11
		

Crossrefs

Cf. A007088 (binary), A175048 (increase 1-bits), A090077 (decrease to single 1-bits).
Cf. A003714 (indices of 0's), A213540 (indices of 1's).
Cf. A106151 (decrease 0-bits), A318921 (decrease each run).

Programs

  • Mathematica
    Table[FromDigits[Flatten[Split@IntegerDigits[n,2]/. {1,a___}:>{a}],2],{n,0,82}] (* Giorgos Kalogeropoulos, Nov 01 2021 *)
  • PARI
    a(n) = my(v=binary(n),t=0); for(i=2,#v, if(v[i-1]||!v[i], v[t++]=v[i])); fromdigits(v[1..t],2);
    
  • Python
    def a(n): return int(bin(n).replace("b", "").replace("01", "0"), 2)
    print([a(n) for n in range(83)]) # Michael S. Branicky, Oct 31 2021
Showing 1-2 of 2 results.