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.

A344259 For any number n with binary expansion (b(1), ..., b(k)), the binary expansion of a(n) is (b(1), ..., b(ceiling(k/2))).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, May 13 2021

Keywords

Comments

Leading zeros are ignored.

Examples

			The first terms, alongside their binary expansion, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1      10          1
   3     1      11          1
   4     2     100         10
   5     2     101         10
   6     3     110         11
   7     3     111         11
   8     2    1000         10
   9     2    1001         10
  10     2    1010         10
  11     2    1011         10
  12     3    1100         11
  13     3    1101         11
  14     3    1110         11
  15     3    1111         11
		

Crossrefs

Programs

  • Mathematica
    Array[FromDigits[First@Partition[l=IntegerDigits[#,2],Ceiling[Length@l/2]],2]&,100,0] (* Giorgos Kalogeropoulos, May 14 2021 *)
  • PARI
    a(n) = n\2^(#binary(n)\2)
    
  • Python
    def a(n): b = bin(n)[2:]; return int(b[:(len(b)+1)//2], 2)
    print([a(n) for n in range(85)]) # Michael S. Branicky, May 14 2021

Formula

a(A020330(n)) = n.
a(A006995(n+1)) = A162751(n).
a(n XOR A344220(n)) = a(n) (where XOR denotes the bitwise XOR operator).

A370427 a(n) is the least k >= 0 such that n OR k is a binary palindrome (where OR denotes the bitwise OR operator).

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 4, 3, 2, 1, 0, 1, 0, 9, 8, 1, 0, 9, 8, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 17, 16, 9, 8, 25, 24, 5, 4, 21, 20, 1, 0, 17, 16, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 33, 32, 17, 16, 49, 48, 1, 0, 33, 32, 17, 16, 49, 48
Offset: 0

Views

Author

Rémy Sigrist, Feb 18 2024

Keywords

Comments

The binary expansions of n and a(n) have no common 1's.

Examples

			The first terms, alongside the corresponding binary expansions, are:
  n   a(n)  bin(n)  bin(a(n))  bin(n OR a(n))
  --  ----  ------  ---------  --------------
   0     0       0          0               0
   1     0       1          0               1
   2     1      10          1              11
   3     0      11          0              11
   4     1     100          1             101
   5     0     101          0             101
   6     1     110          1             111
   7     0     111          0             111
   8     1    1000          1            1001
   9     0    1001          0            1001
  10     5    1010        101            1111
  11     4    1011        100            1111
  12     3    1100         11            1111
  13     2    1101         10            1111
  14     1    1110          1            1111
  15     0    1111          0            1111
		

Crossrefs

Cf. A006995, A030101, A175297, A344220 (XOR variant).

Programs

  • Mathematica
    A370427[n_] := With[{r = IntegerReverse[n, 2]}, r - BitAnd[n, r]];
    Array[A370427, 2^7, 0] (* Paolo Xausa, Feb 20 2024 *)
  • PARI
    a(n) = my (r = fromdigits(Vecrev(binary(n)), 2)); r - bitand(n, r)

Formula

n AND a(n) = 0 (where AND denotes the bitwise AND operator).
a(n) = A030101(n) - (n AND A030101(n)).
a(n) = A030101(n) - A175297(n) (for any n > 0).
a(n) = 0 iff n belongs to A006995.
Showing 1-2 of 2 results.