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.

Previous Showing 11-15 of 15 results.

A381839 In the binary expansion of n (without leading zeros): complement the bits strictly between the leftmost and the rightmost 0's, if any.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 10, 9, 8, 11, 12, 13, 14, 15, 22, 21, 20, 19, 18, 17, 16, 23, 26, 25, 24, 27, 28, 29, 30, 31, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 47, 54, 53, 52, 51, 50, 49, 48, 55, 58, 57, 56, 59, 60, 61, 62, 63, 94, 93, 92, 91
Offset: 0

Views

Author

Rémy Sigrist, Mar 08 2025

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers.
This sequence has similarities with A122155 (where we complement bits between the leftmost and the rightmost 1's).
This sequence has infinitely many fixed points: A000225, A030130, and the positive numbers whose binary expansion have exactly two 0's that are also adjacent to each other.

Examples

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

Crossrefs

Programs

  • PARI
    a(n) = { my (b = binary(n)); for (i = 1, #b, if (b[i]==0, forstep (j = #b, 1, -1, if (b[j]==0, for (k = i+1, j-1, b[k] = 1-b[k];); return (fromdigits(b, 2)););););); return (n); }
    
  • Python
    def a(n):
        b = bin(n)[2:]
        zl, zr = b.find('0'), b.rfind('0')
        return n if abs(zl-zr) < 2 else int(b[:zl+1]+"".join('0' if bi == '1' else '1' for bi in b[zl+1:zr])+b[zr:], 2)
    print([a(n) for n in range(70)]) # Michael S. Branicky, Mar 09 2025
    
  • Python
    def A381839(n): return n^((1<1 else n # Chai Wah Wu, Mar 09 2025

Formula

a(2*n + 1) = 2*a(n) + 1.

A175039 Minimum number of integer-sided squares needed to tile an n-row staircase (a figure with n unit squares in the n-th row, and the leftmost squares of each row vertically aligned).

Original entry on oeis.org

1, 3, 3, 7, 6, 7, 7, 11, 12, 13, 12, 15, 14, 15, 15, 20, 20, 23, 22, 23, 24, 25, 24, 29, 28, 29, 28
Offset: 1

Views

Author

Cyril Zhang, Apr 04 2010

Keywords

Comments

a(n) >= n, since the rightmost squares in each row must be covered by distinct tiles.
a(n) = n iff n = 2^k - 1.
a(n) = n+1 iff n = 2^k - 2^m - 1.
a(2*k) <= 2*a(k) + 1, a(2*k+1) <= 2*a(k) + 1 for k >= 1. - Jinyuan Wang, Jul 17 2019
a(n) <= A003817(n). - Austin Shapiro, Dec 29 2022

Examples

			See link for diagrams of tilings.
		

Crossrefs

Solutions for a(n) = n: A000225. Solutions for a(n) = n+1: A030130, excluding 0.

A384021 Powers of 2 along with numbers one power of 2 less than binary repunits, but the power of two subtracted does not flip the leading bit.

Original entry on oeis.org

1, 2, 4, 5, 6, 8, 11, 13, 14, 16, 23, 27, 29, 30, 32, 47, 55, 59, 61, 62, 64, 95, 111, 119, 123, 125, 126, 128, 191, 223, 239, 247, 251, 253, 254, 256, 383, 447, 479, 495, 503, 507, 509, 510, 512, 767, 895, 959, 991, 1007, 1015, 1019, 1021, 1022, 1024, 1535, 1791, 1919
Offset: 1

Views

Author

David A. Corneth, May 17 2025

Keywords

Comments

Also numbers where in the binary expansion the bit 0 or 1 occurs exactly once.
Union of A000079 and A164874. - Chai Wah Wu, May 21 2025

Examples

			4 = 2^2 is term as it is a power of 2.
5 is a term as 5 = (2^3 - 1) - 2^1; a power of two less than a binary repunit and subtracting 2 from 7 does not flip the most significant bit of 7.
		

Crossrefs

Cf. A383666 (complement), A000079, A030130, A164874.

Programs

  • Mathematica
    A384021list[k_] := Flatten[{1, Table[{2^i - 1 - BitShiftRight[2^i, Range[2, i]], 2^i}, {i, 2 - Boole[k == 1], k}]}]; (* returns terms up to 2^k *)
    A384021list[11] (* Paolo Xausa, Jun 12 2025 *)
  • PARI
    upto(n) = {
        my(res = List());
        for(i = 0, logint(n, 2)+1,
            pow2 = 1<
    				
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        yield from (1, 2)
        for d in count(3):
            m, b1 = 1<<(d-1), (1<>i) for i in range(1, d))
    print(list(islice(agen(), 58))) # Michael S. Branicky, May 18 2025
    
  • Python
    def A384021(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            kmin = kmax >> 1		
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x):
            if x<=1: return n
            l, s = x.bit_length(), bin(x)[2:]
            if (m:=s.count('0'))>0: return n+x-s.index('0')+(m>1)-(l*(l-1)>>1)
            return n+x+1-(l*(l+1)>>1)
        return bisection(f,n,n) # Chai Wah Wu, May 21 2025

A384189 Numbers whose number of zeros in their binary representation is not equal to 1.

Original entry on oeis.org

1, 3, 4, 7, 8, 9, 10, 12, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82
Offset: 1

Views

Author

Chai Wah Wu, May 21 2025

Keywords

Comments

Numbers m such that A023416(m) != 1. Complement of A030130.

Examples

			15 is a term since its binary representation 1111 has no zeros.
53 is a term since its binary representation 110101 has two zeros.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[100], DigitCount[#, 2, 0] != 1 &] (* Paolo Xausa, May 22 2025 *)
  • Python
    def A384189(n):
        def f(x):
            l, s = x.bit_length(), bin(x)[2:]
            if (m:=s.count('0'))>0: return n+s.find('0')+((m>1)^1)+(l*(l-3)>>1)
            return n+(l*(l-1)>>1)
        m, k = n, f(n)
        while m != k: m, k = k, f(k)
        return m

A118681 Numbers that contain a single zero in bases 2 and 10.

Original entry on oeis.org

0, 30, 503, 507, 509, 510, 1015, 1019, 1021, 1022, 2015, 2031, 2039, 2043, 2045, 2046, 3071, 4031, 4063, 4079, 4087, 4091, 4093, 4094, 8063, 8190, 30719, 32703, 65023, 65407, 65503, 98303, 129023, 130559, 130815, 130943, 131039, 131055
Offset: 1

Views

Author

Zak Seidov, May 21 2006

Keywords

Crossrefs

Intersection of A030130 and A043489.

Programs

  • Mathematica
    Select[Range[0,140000],DigitCount[#,10,0]==DigitCount[#,2,0]==1&] (* Harvey P. Dale, Apr 10 2012 *)
Previous Showing 11-15 of 15 results.