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-7 of 7 results.

A144624 a(n) = A078823(n) - n.

Original entry on oeis.org

0, 0, 1, 1, 3, 3, 6, 4, 7, 7, 8, 11, 16, 17, 19, 11, 15, 15, 16, 19, 22, 18, 28, 29, 36, 37, 40, 41, 49, 51, 48, 26, 31, 31, 32, 35, 34, 39, 44, 45, 50, 51, 39, 53, 66, 63, 72, 67, 76, 77, 80, 81, 90, 87, 90, 98, 109, 111, 116, 118, 122, 125, 109, 57, 63, 63, 64, 67, 66, 71, 76
Offset: 0

Views

Author

N. J. A. Sloane, Jan 18 2009

Keywords

Comments

Sum of all distinct binary numbers contained as proper substrings in the binary representation of n.

Programs

Extensions

Extended by Ray Chandler, Mar 13 2010

A078822 Number of distinct binary numbers contained as substrings in the binary representation of n.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Dec 08 2002

Keywords

Comments

For n>0: 0A070939(n)+1, 0A070939(n). - Reinhard Zumkeller, Mar 07 2008
Row lengths in triangle A119709. - Reinhard Zumkeller, Aug 14 2013

Examples

			n=10 -> '1010' contains 5 different binary numbers: '0' (b0bb or bbb0), '1' (1bbb or bb1b), '10' (10bb or bb10), '101' (101b) and '1010' itself, therefore a(10)=5.
		

Crossrefs

Programs

  • Haskell
    a078822 = length . a119709_row
    import Numeric (showIntAtBase)
    -- Reinhard Zumkeller, Aug 13 2013, Sep 14 2011
    
  • Maple
    a:= n-> (s-> nops({seq(seq(parse(s[i..j]), i=1..j),
            j=1..length(s))}))(""||(convert(n, binary))):
    seq(a(n), n=0..85);  # Alois P. Heinz, Jan 20 2021
  • Mathematica
    a[n_] := (id = IntegerDigits[n, 2]; nd = Length[id]; Length[ Union[ Flatten[ Table[ id[[j ;; k]], {j, 1, nd}, {k, j, nd}], 1] //. {0, b__} :> {b}]]); Table[ a[n], {n, 0, 85}] (* Jean-François Alcover, Dec 01 2011 *)
  • PARI
    a(n) = {if (n==0, 1, vb = binary(n); vf = []; for (i=1, #vb, for (j=1, #vb - i + 1, pvb = vector(j, k, vb[i+k-1]); f = subst(Pol(pvb), x, 2); vf = Set(concat(vf, f)); ); ); #vf); } \\ Michel Marcus, May 08 2016; corrected Jun 13 2022
    
  • Python
    def a(n): return 1 if n == 0 else len(set(((((2<>i for i in range(n.bit_length()) for l in range(n.bit_length()-i)))
    print([a(n) for n in range(64)]) # Michael S. Branicky, Jul 28 2022

Formula

For k>0: a(2^k-2) = 2*(k-1)+1, a(2^k-1) = k, a(2^k) = k+2;
for k>1: a(2^k+1) = k+2;
for k>0: a(2^k-1) = A078824(2^k-1), a(2^k) = A078824(2^k).

A165153 a(n) = the product of all distinct positive (nonzero) integers that, when written in binary, occur as substrings in the binary representation of n.

Original entry on oeis.org

1, 2, 3, 8, 10, 36, 21, 64, 72, 100, 330, 1728, 2340, 3528, 315, 1024, 1088, 1296, 4104, 8000, 2100, 43560, 53130, 331776, 388800, 608400, 694980, 4741632, 6650280, 1587600, 9765, 32768, 33792, 36992, 114240, 46656, 239760, 935712, 1120392
Offset: 1

Views

Author

Leroy Quet, Sep 05 2009

Keywords

Crossrefs

Programs

Formula

a(n) = product(A165416(n,k): k=1..A078822(n)-1). - Reinhard Zumkeller, Aug 14 2013

Extensions

More terms from Sean A. Irvine, Nov 12 2009

A356150 a(n) is the sum of the positive integers whose binary expansion appears as a substring in the binary expansion of n or its complement.

Original entry on oeis.org

1, 3, 4, 10, 8, 12, 11, 25, 25, 18, 26, 28, 30, 33, 26, 56, 62, 61, 56, 56, 39, 63, 64, 67, 62, 66, 72, 77, 80, 78, 57, 119, 139, 143, 137, 135, 134, 119, 134, 134, 134, 81, 120, 138, 139, 147, 142, 146, 147, 148, 132, 153, 140, 157, 165, 165, 168, 174, 181
Offset: 1

Views

Author

Rémy Sigrist, Jul 28 2022

Keywords

Comments

Leading 0's in binary expansions are ignored.

Examples

			For n = 11:
- row 11 of A356149 is 1, 2, 3, 4, 5, 11,
- so a(11) = 1 + 2 + 3 + 4 + 5 + 11 = 26.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (b=binary(n)); vecsum(setbinop((i,j) -> my (s=fromdigits(b[i..j],2)); if (b[i], s, 2^(j-i+1)-1-s), [1..#b])) }
    
  • Python
    def a(n):
        N = n.bit_length()
        c, s = ((1<> i)
                s.add((mask&c) >> i)
        return sum(s)
    print([a(n) for n in range(1, 60)]) # Michael S. Branicky, Jul 28 2022

Formula

a(n) >= A078823(n).
a(n) Sum_{k = 1..A356148(n)} A356149(n, k).

A078825 Sum of distinct binary numbers contained as substrings in binary, circular formed representation of n and not longer than n.

Original entry on oeis.org

0, 1, 3, 4, 7, 17, 17, 11, 15, 37, 18, 62, 37, 62, 62, 26, 31, 77, 69, 130, 69, 120, 120, 186, 77, 130, 120, 186, 130, 186, 186, 57, 63, 157, 141, 266, 70, 249, 249, 382, 141, 249, 81, 371, 249, 189, 371, 501, 157, 266, 249, 382, 249, 371, 189, 501, 266, 382
Offset: 0

Views

Author

Reinhard Zumkeller, Dec 08 2002

Keywords

Comments

a(2^k-1)=2^(k+1)-(k+2); a(2^k)=2^(k+1)-1;
for k>0: a(2^k+1)=a(3*2^(k-1))=2^(k+1);
a(2^k-1)=A078823(2^k-1), a(2^k)=A078823(2^k).

Crossrefs

A328379 a(n) is the sum of the distinct numbers whose binary digits appear in order but not necessarily as consecutive digits in the binary representation of n.

Original entry on oeis.org

0, 1, 3, 4, 7, 11, 12, 11, 15, 24, 31, 29, 28, 37, 33, 26, 31, 49, 66, 61, 71, 92, 85, 67, 60, 87, 103, 90, 77, 95, 78, 57, 63, 98, 133, 121, 150, 191, 177, 138, 151, 215, 254, 219, 197, 240, 199, 145, 124, 185, 237, 210, 235, 293, 262, 199, 165, 230, 263, 223
Offset: 0

Views

Author

Rémy Sigrist, Nov 30 2019

Keywords

Examples

			The first terms, alongside the binary representations of n as well as those of the numbers that appear in it, are:
  n   a(n)  bin(n)  {bin(s)}
  --  ----  ------  ----------------------------
   0     0       0  {0}
   1     1       1  {1}
   2     3      10  {0, 1, 10}
   3     4      11  {1, 11}
   4     7     100  {0, 1, 10, 100}
   5    11     101  {0, 1, 10, 11, 101}
   6    12     110  {0, 1, 10, 11, 110}
   7    11     111  {1, 11, 111}
   8    15    1000  {0, 1, 10, 100, 1000}
   9    24    1001  {0, 1, 10, 11, 100, 101, 1001}
  10    31    1010  {0, 1, 10, 11, 100, 101, 110, 1010}
		

Crossrefs

Programs

  • PARI
    a(n, base=2) = { my (b=digits(n, base), s=[0]); for (k=1, #b, s = setunion(s, apply(o -> base*o+b[k], s))); vecsum(s) }

Formula

A078823(n) <= a(n).
a(2^k) = 2^(k+1)-1 for any k >= 0.
a(2^k-1) = A000295(k+1) for any k >= 0.

A330072 a(n) is the sum of all integers whose binary representation is contained in the binary representation of n (with multiplicity).

Original entry on oeis.org

0, 1, 3, 5, 7, 10, 13, 16, 15, 19, 24, 28, 29, 33, 38, 42, 31, 36, 43, 48, 52, 57, 64, 69, 61, 66, 73, 78, 82, 87, 94, 99, 63, 69, 78, 84, 91, 97, 106, 112, 108, 114, 123, 129, 136, 142, 151, 157, 125, 131, 140, 146, 153, 159, 168, 174, 170, 176, 185, 191, 198
Offset: 0

Views

Author

Tonio Kettner, Nov 30 2019

Keywords

Examples

			For n = 5: 5 in binary is 101, so a(n) = 101 + 10 + 01 + 1 + 0 + 1 in binary, which is 5 + 2 + 1 + 1 + 0 + 1 = 10.
		

Crossrefs

Cf. A007088, A005187, A049802, A078823, A225580 (base-10 version).

Programs

  • Mathematica
    a[n_] := Block[{d = IntegerDigits[n, 2]}, Sum[FromDigits[Take[d, {i, j}], 2], {j, Length[d]}, {i, j}]]; Array[a, 61, 0] (* Giovanni Resta, Dec 02 2019 *)
  • Python
    def bitlist(n):
        output = []
        while n != 0:
            output.append(n % 2)
            n //= 2
        return output
    #converts a number into a list of the digits in binary reversed
    def bitsum(bitlist):
        output = 0
        for bit in bitlist:
            if bit == 1:
                output += 1
        return output
    #gives the cross sum of a bitlist
    def a(bitlist):
        output = 0
        l = len(bitlist)
        for x in range(l):
            output += bitlist[x] * (l - x) * (2**(x + 1) - 1)
        return output
    #to get the first 60 numbers of the sequence, write:
    for x in range(0, 60):
        print(a(bitlist(x)))
    
  • Python
    def a(n):
        b = n.bit_length()
        return sum((n//2**i) % (2**j) for i in range(b+1) for j in range(b-i+1))
    # David Radcliffe, May 14 2025

Formula

a(2^k) = 2^(k+1)-1.
a(2^k-1) = (8*2^k-8-5*k-k^2)/2. - Giovanni Resta, Dec 02 2019
From David Radcliffe, May 14 2025: (Start)
a(n) = Sum_{i=0..b} Sum_{j=0..b-i} ([n/2^i] mod 2^j) where b is the bit length of n.
a(n) - 3a([n/2]) + 2a([n/4]) = A070939(n) if n is odd, 0 otherwise. (End)
Showing 1-7 of 7 results.