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

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).

A141298 a(n) = number of distinct substrings in the binary representation of n that each occur multiple times.

Original entry on oeis.org

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

Views

Author

Leroy Quet, Jun 24 2008

Keywords

Comments

Substrings may start with a 0.

Examples

			The distinct substrings that occur multiple times in decimal 10 = binary 1010 are 0,1 and 10. So a(10)=3.
		

Crossrefs

Programs

Extensions

Extended by Ray Chandler, Jun 25 2009

A141299 a(n) = number (with repetition) of (not necessarily distinct) substrings in the binary representation of n that each occur multiple times.

Original entry on oeis.org

0, 0, 2, 2, 2, 2, 5, 5, 4, 6, 3, 4, 3, 5, 9, 9, 7, 7, 5, 7, 11, 7, 6, 7, 5, 7, 6, 7, 6, 9, 14, 14, 11, 10, 8, 12, 10, 8, 8, 10, 10, 17, 12, 8, 12, 10, 10, 11, 8, 8, 8, 8, 12, 12, 8, 10, 8, 10, 8, 11, 10, 14, 20, 20, 16, 14, 12, 14, 13, 11, 11, 14, 19, 14, 11, 13, 11, 11, 12, 14, 13, 14, 11
Offset: 1

Views

Author

Leroy Quet, Jun 24 2008

Keywords

Comments

Substrings may start with a 0.

Examples

			0,0,1,1,10,10 each occur multiple times in binary 1010 = decimal 10. So a(10) = 6.
		

Crossrefs

Programs

  • Mathematica
    Array[Function[d, Total@ Select[Tally@ Apply[Join, Map[Partition[d, #, 1] &, Range[Length@ d - 1]]], Last@ # > 1 &][[All, -1]]]@ IntegerDigits[#, 2] &, 83] (* Michael De Vlieger, Oct 23 2017 *)

Extensions

Extended by Ray Chandler, Jun 25 2009

A141300 a(n) = number of distinct (nonempty) substrings in the binary representation of n that each occur exactly once.

Original entry on oeis.org

1, 3, 1, 4, 4, 4, 1, 5, 6, 4, 7, 6, 7, 5, 1, 6, 8, 8, 10, 8, 4, 8, 9, 8, 10, 8, 9, 8, 9, 6, 1, 7, 10, 11, 13, 9, 11, 13, 13, 11, 11, 4, 9, 13, 9, 11, 11, 10, 13, 13, 13, 13, 9, 9, 13, 11, 13, 11, 13, 10, 11, 7, 1, 8, 12, 14, 16, 14, 15, 17, 17, 14, 9, 14, 17, 15, 17, 17, 16, 14, 15, 14, 17
Offset: 1

Views

Author

Leroy Quet, Jun 24 2008

Keywords

Comments

Substrings may start with a 0.

Examples

			In (decimal 10 =) binary 1010: 01, 101, 010, 1010 each occur exactly once. So a(10) = 4.
		

Crossrefs

Programs

Extensions

Extended by Ray Chandler, Jun 25 2009

A293722 Number of distinct nonempty subsequences of the binary expansion of n.

Original entry on oeis.org

1, 1, 3, 2, 5, 6, 5, 3, 7, 10, 11, 9, 8, 9, 7, 4, 9, 14, 17, 15, 16, 19, 17, 12, 11, 15, 16, 13, 11, 12, 9, 5, 11, 18, 23, 21, 24, 29, 27, 20, 21, 29, 32, 27, 25, 28, 23, 15, 14, 21, 25, 22, 23, 27, 24, 17, 15, 20, 21, 17, 14, 15, 11, 6, 13, 22, 29, 27, 32, 39, 37
Offset: 0

Views

Author

Orson R. L. Peters, Oct 15 2017

Keywords

Comments

The subsequence does not need to consist of adjacent terms.

Examples

			a(4) = 5 because 4 = 100_2, and the distinct subsequences of 100 are 0, 1, 00, 10, 100.
Similarly a(7) = 3, because 7 = 111_2, and 111 has only three distinct subsequences: 1, 11, 111.
a(9) = 10: 9 = 1001_2, and we get 0, 1, 00, 01, 10, 11, 001, 100, 101, 1001.
		

Crossrefs

Cf. A141297.
If the empty subsequence is also counted, we get A293170.

Programs

  • Python
    def a(n):
        if n == 0: return 1
        r, l = 1, [0, 0]
        while n:
            r, l[n%2] = 2*r - l[n%2], r
            n >>= 1
        return r - 1

Formula

a(2^n) = 2n + 1.
a(2^n-1) = n if n>0.
a(n) = A293170(n) - 1. - Andrew Howroyd, Apr 27 2020

Extensions

Terms a(50) and beyond from Andrew Howroyd, Apr 27 2020
Showing 1-5 of 5 results.