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-10 of 14 results. Next

A029931 If 2n = Sum 2^e_i, a(n) = Sum e_i.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Write n in base 2, n = sum b(i)*2^(i-1), then a(n) = sum b(i)*i. - Benoit Cloitre, Jun 09 2002
May be regarded as a triangular array read by rows, giving weighted sum of compositions in standard order. The standard order of compositions is given by A066099. - Franklin T. Adams-Watters, Nov 06 2006
Sum of all positive integer roots m_i of polynomial {m,k} - see link [Shevelev]; see also A264613. - Vladimir Shevelev, Dec 13 2015
Also the sum of binary indices of n, where a binary index of n (A048793) is any position of a 1 in its reversed binary expansion. For example, the binary indices of 11 are {1,2,4}, so a(11) = 7. - Gus Wiseman, May 22 2024

Examples

			14 = 8+4+2 so a(7) = 3+2+1 = 6.
Composition number 11 is 2,1,1; 1*2+2*1+3*1 = 7, so a(11) = 7.
The triangle starts:
  0
  1
  2 3
  3 4 5 6
The reversed binary expansion of 18 is (0,1,0,0,1) with 1's at positions {2,5}, so a(18) = 2 + 5 = 7. - _Gus Wiseman_, Jul 22 2019
		

Crossrefs

Other sequences that are built by replacing 2^k in the binary representation with other numbers: A022290 (Fibonacci), A059590 (factorials), A073642, A089625 (primes), A116549, A326031.
Cf. A001793 (row sums), A011782 (row lengths), A059867, A066099, A124757.
Row sums of A048793 and A272020.
Contains exactly A000009(n) copies of n.
For length instead of sum we have A000120, complement A023416.
For minimum instead of sum we have A001511, opposite A000012.
For maximum instead of sum we have A029837 or A070939, opposite A070940.
For product instead of sum we have A096111.
The reverse version is A230877, row sums of A371572.
The reverse complement is A359359, row sums of A371571.
The complement is A359400, row sums of A368494.
Numbers k such that a(k) is prime are A372689.
A014499 lists binary indices of prime numbers.
A019565 gives Heinz number of binary indices, inverse A048675.
A372471 lists binary indices of primes, row-sums A372429.

Programs

  • Haskell
    a029931 = sum . zipWith (*) [1..] . a030308_row
    -- Reinhard Zumkeller, Feb 28 2014
    
  • Maple
    HammingWeight := n -> add(i, i = convert(n, base, 2)):
    a := proc(n) option remember; `if`(n = 0, 0,
    ifelse(n::even, a(n/2) + HammingWeight(n/2), a(n-1) + 1)) end:
    seq(a(n), n = 0..78); # Peter Luschny, Oct 30 2021
  • Mathematica
    a[n_] := (b = IntegerDigits[n, 2]).Reverse @ Range[Length @ b]; Array[a,78,0] (* Jean-François Alcover, Apr 28 2011, after B. Cloitre *)
  • PARI
    for(n=0,100,l=length(binary(n)); print1(sum(i=1,l, component(binary(n),i)*(l-i+1)),","))
    
  • PARI
    a(n) = my(b=binary(n)); b*-[-#b..-1]~; \\ Ruud H.G. van Tol, Oct 17 2023
    
  • Python
    def A029931(n): return sum(i if j == '1' else 0 for i, j in enumerate(bin(n)[:1:-1],1)) # Chai Wah Wu, Dec 20 2022
    (C#)
    ulong A029931(ulong n) {
        ulong result = 0, counter = 1;
        while(n > 0) {
            if (n % 2 == 1)
              result += counter;
            counter++;
            n /= 2;
        }
        return result;
    } // Frank Hollstein, Jan 07 2023

Formula

a(n) = a(n - 2^L(n)) + L(n) + 1 [where L(n) = floor(log_2(n)) = A000523(n)] = sum of digits of A048794 [at least for n < 512]. - Henry Bottomley, Mar 09 2001
a(0) = 0, a(2n) = a(n) + e1(n), a(2n+1) = a(2n) + 1, where e1(n) = A000120(n). a(n) = log_2(A029930(n)). - Ralf Stephan, Jun 19 2003
G.f.: (1/(1-x)) * Sum_{k>=0} (k+1)*x^2^k/(1+x^2^k). - Ralf Stephan, Jun 23 2003
a(n) = Sum_{k>=0} A030308(n,k)*A000027(k+1). - Philippe Deléham, Oct 15 2011
a(n) = sum of n-th row of the triangle in A213629. - Reinhard Zumkeller, Jun 17 2012
From Reinhard Zumkeller, Feb 28 2014: (Start)
a(A089633(n)) = n and a(m) != n for m < A089633(n).
a(n) = Sum_{k=1..A070939(n)} k*A030308(n,k-1). (End)
a(n) = A073642(n) + A000120(n). - Peter Kagey, Apr 04 2016

Extensions

More terms from Erich Friedman

A359359 Sum of positions of zeros in the binary expansion of n, where positions are read starting with 1 from the left (big-endian).

Original entry on oeis.org

1, 0, 2, 0, 5, 2, 3, 0, 9, 5, 6, 2, 7, 3, 4, 0, 14, 9, 10, 5, 11, 6, 7, 2, 12, 7, 8, 3, 9, 4, 5, 0, 20, 14, 15, 9, 16, 10, 11, 5, 17, 11, 12, 6, 13, 7, 8, 2, 18, 12, 13, 7, 14, 8, 9, 3, 15, 9, 10, 4, 11, 5, 6, 0, 27, 20, 21, 14, 22, 15, 16, 9, 23, 16, 17, 10
Offset: 0

Views

Author

Gus Wiseman, Jan 03 2023

Keywords

Examples

			The binary expansion of 100 is (1,1,0,0,1,0,0), with zeros at positions {3,4,6,7}, so a(100) = 20.
		

Crossrefs

The number of zeros is A023416, partial sums A059015.
For positions of 1's we have A230877, reversed A029931.
The reversed version is A359400.
A003714 lists numbers with no successive binary indices.
A030190 gives binary expansion.
A039004 lists the positions of zeros in A345927.

Programs

  • Mathematica
    Table[Total[Join@@Position[IntegerDigits[n,2],0]],{n,0,100}]

Formula

a(n>0) = binomial(A029837(n)+1,2) - A230877(n).

A359400 Sum of positions of zeros in the reversed binary expansion of n, where positions in a sequence are read starting with 1 from the left.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jan 05 2023

Keywords

Examples

			The reversed binary expansion of 100 is (0,0,1,0,0,1,1), with zeros at positions {1,2,4,5}, so a(100) = 12.
		

Crossrefs

The number of zeros is A023416, partial sums A059015.
Row sums of A368494.
For positions of 1's we have A029931, non-reversed A230877.
The non-reversed version is A359359.
A003714 lists numbers with no successive binary indices.
A030190 gives binary expansion, reverse A030308.
A039004 lists the positions of zeros in A345927.

Programs

  • C
    long A359400(long n) {
      long result = 0, counter = 1;
      do {
        if (n % 2 == 0)
          result += counter;
        counter++;
        n /= 2;
      } while (n > 0);
      return result; } // Frank Hollstein, Jan 06 2023
    
  • Mathematica
    Table[Total[Join@@Position[Reverse[IntegerDigits[n,2]],0]],{n,0,100}]
  • Python
    def a(n): return sum(i for i, bi in enumerate(bin(n)[:1:-1], 1) if bi=='0')
    print([a(n) for n in range(78)]) # Michael S. Branicky, Jan 09 2023

Formula

a(n) = binomial(A029837(n)+1, 2) - A029931(n), for n>0.

A372427 Numbers whose binary indices and prime indices have the same sum.

Original entry on oeis.org

19, 33, 34, 69, 74, 82, 130, 133, 305, 412, 428, 436, 533, 721, 755, 808, 917, 978, 1036, 1058, 1062, 1121, 1133, 1143, 1341, 1356, 1630, 1639, 1784, 1807, 1837, 1990, 2057, 2115, 2130, 2133, 2163, 2260, 2324, 2328, 2354, 2358, 2512, 2534, 2627, 2771, 2825
Offset: 1

Views

Author

Gus Wiseman, May 01 2024

Keywords

Comments

A binary index of n is any position of a 1 in its reversed binary expansion. The binary indices of n are row n of A048793.
A prime index of n is a number m such that prime(m) divides n. The multiset of prime indices of n is row n of A112798.

Examples

			The binary indices of 130 are {2,8}, and the prime indices are {1,3,6}. Both sum to 10, so 130 is in the sequence.
The terms together with their prime indices begin:
   19: {8}
   33: {2,5}
   34: {1,7}
   69: {2,9}
   74: {1,12}
   82: {1,13}
  130: {1,3,6}
  133: {4,8}
  305: {3,18}
  412: {1,1,27}
  428: {1,1,28}
The terms together with their binary expansions and binary indices begin:
   19:      10011 ~ {1,2,5}
   33:     100001 ~ {1,6}
   34:     100010 ~ {2,6}
   69:    1000101 ~ {1,3,7}
   74:    1001010 ~ {2,4,7}
   82:    1010010 ~ {2,5,7}
  130:   10000010 ~ {2,8}
  133:   10000101 ~ {1,3,8}
  305:  100110001 ~ {1,5,6,9}
  412:  110011100 ~ {3,4,5,8,9}
  428:  110101100 ~ {3,4,6,8,9}
		

Crossrefs

For length instead of sum we get A071814.
Positions of zeros in A372428.
For maximum instead of sum we have A372436.
A003963 gives product of prime indices.
A019565 gives Heinz number of binary indices, adjoint A048675.
A029837 gives greatest binary index, least A001511.
A048793 lists binary indices, length A000120, reverse A272020, sum A029931.
A061395 gives greatest prime index, least A055396.
A070939 gives length of binary expansion.
A096111 gives product of binary indices.
A112798 lists prime indices, length A001222, reverse A296150, sum A056239.
A326031 gives weight of the set-system with BII-number n.

Programs

  • Mathematica
    prix[n_]:=If[n==1,{},Flatten[Cases[FactorInteger[n],{p_,k_}:>Table[PrimePi[p],{k}]]]];
    bix[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    Select[Range[100],Total[prix[#]]==Total[bix[#]]&]

A372436 Numbers whose binary indices and prime indices have the same maximum.

Original entry on oeis.org

3, 5, 14, 22, 39, 52, 68, 85, 102, 119, 133, 152, 171, 190, 209, 228, 247, 276, 299, 322, 345, 368, 391, 414, 437, 460, 483, 506, 522, 551, 580, 609, 638, 667, 696, 725, 754, 783, 812, 841, 870, 928, 957, 986, 1015, 1054, 1085, 1116, 1178, 1209, 1240, 1302
Offset: 1

Views

Author

Gus Wiseman, May 04 2024

Keywords

Comments

A binary index of n is any position of a 1 in its reversed binary expansion. The binary indices of n are row n of A048793.
A prime index of n is a number m such that prime(m) divides n. The multiset of prime indices of n is row n of A112798.
Note that a number's binary and prime indices cannot have the same minimum; see A372437.

Examples

			The binary indices of 345 are {1,4,5,7,9}, and the prime indices are {2,3,9}. Both have maximum 9, so 345 is in the sequence.
The terms together with their prime indices begin:
     3: {2}
     5: {3}
    14: {1,4}
    22: {1,5}
    39: {2,6}
    52: {1,1,6}
    68: {1,1,7}
    85: {3,7}
   102: {1,2,7}
   119: {4,7}
   133: {4,8}
   152: {1,1,1,8}
   171: {2,2,8}
The terms together with their binary expansions and binary indices begin:
     3:           11 ~ {1,2}
     5:          101 ~ {1,3}
    14:         1110 ~ {2,3,4}
    22:        10110 ~ {2,3,5}
    39:       100111 ~ {1,2,3,6}
    52:       110100 ~ {3,5,6}
    68:      1000100 ~ {3,7}
    85:      1010101 ~ {1,3,5,7}
   102:      1100110 ~ {2,3,6,7}
   119:      1110111 ~ {1,2,3,5,6,7}
   133:     10000101 ~ {1,3,8}
   152:     10011000 ~ {4,5,8}
   171:     10101011 ~ {1,2,4,6,8}
		

Crossrefs

For length instead of maximum we have A071814.
For sum instead of maximum we have A372427.
Positions of zeros in A372442, for minimum instead of maximum A372437.
A003963 gives product of prime indices.
A019565 gives Heinz number of binary indices, adjoint A048675.
A029837 gives greatest binary index, least A001511.
A048793 lists binary indices, length A000120, reverse A272020, sum A029931.
A061395 gives greatest prime index, least A055396.
A070939 gives length of binary expansion.
A112798 lists prime indices, length A001222, reverse A296150, sum A056239.

Programs

  • Mathematica
    bix[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    prix[n_]:=If[n==1,{},Flatten[Cases[FactorInteger[n],{p_,k_}:>Table[PrimePi[p],{k}]]]];
    Select[Range[100],Max[prix[#]]==Max[bix[#]]&]

Formula

A070939(a(n)) = A061395(a(n)).

A124757 Zero-based weighted sum of compositions in standard order.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The standard order of compositions is given by A066099.
Sum of all positions of 1's except the last in the reversed binary expansion of n. For example, the reversed binary expansion of 14 is (0,1,1,1), so a(14) = 2 + 3 = 5. Keeping the last position gives A029931. - Gus Wiseman, Jan 17 2023

Examples

			Composition number 11 is 2,1,1; 0*2+1*1+2*1 = 3, so a(11) = 3.
The table starts:
  0
  0
  0 1
  0 1 2 3
		

Crossrefs

Cf. A066099, A070939, A029931, A011782 (row lengths), A001788 (row sums).
Row sums of A048793 if we delete the last part of every row.
For prime indices instead of standard comps we have A359674, rev A359677.
Positions of first appearances are A359756.
A003714 lists numbers with no successive binary indices.
A030190 gives binary expansion, reverse A030308.
A230877 adds up positions of 1's in binary expansion, length A000120.
A359359 adds up positions of 0's in binary expansion, length A023416.

Programs

  • Mathematica
    Table[Total[Most[Join@@Position[Reverse[IntegerDigits[n,2]],1]]],{n,30}]

Formula

For a composition b(1),...,b(k), a(n) = Sum_{i=1..k} (i-1)*b(i).
For n>0, a(n) = A029931(n) - A070939(n).

A359495 Sum of positions of 1's in binary expansion minus sum of positions of 1's in reversed binary expansion, where positions in a sequence are read starting with 1 from the left.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jan 05 2023

Keywords

Comments

Also the sum of partial sums of reversed binary expansion minus sum of partial sums of binary expansion.

Examples

			The binary expansion of 158 is (1,0,0,1,1,1,1,0), with positions of 1's {1,4,5,6,7} with sum 23, reversed {2,3,4,5,8} with sum 22, so a(158) = 1.
		

Crossrefs

Indices of positive terms are A359401.
Indices of 0's are A359402.
A030190 gives binary expansion, reverse A030308.
A070939 counts binary digits.
A230877 adds up positions of 1's in binary expansion, reverse A029931.

Programs

  • Maple
    a:= n-> (l-> add(i*(l[-i]-l[i]), i=1..nops(l)))(Bits[Split](n)):
    seq(a(n), n=0..127);  # Alois P. Heinz, Jan 09 2023
  • Mathematica
    sap[q_]:=Sum[q[[i]]*(2i-Length[q]-1),{i,Length[q]}];
    Table[sap[IntegerDigits[n,2]],{n,0,100}]
  • Python
    def A359495(n):
        k = n.bit_length()-1
        return sum((i<<1)-k for i, j in enumerate(bin(n)[2:]) if j=='1') # Chai Wah Wu, Jan 09 2023

Formula

a(n) = A029931(n) - A230877(n).
If n = Sum_{i=1..k} q_i * 2^(i-1), then a(n) = Sum_{i=1..k} q_i * (2i-k-1).

A372437 (Least binary index of n) minus (least prime index of n).

Original entry on oeis.org

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

Views

Author

Gus Wiseman, May 06 2024

Keywords

Comments

A binary index of n is any position of a 1 in its reversed binary expansion. The binary indices of n are row n of A048793.
A prime index of n is a number m such that prime(m) divides n. The multiset of prime indices of n is row n of A112798.
Is 0 the only integer not appearing in the data?

Crossrefs

Positions of first appearances are A174090.
For sum instead of minimum we have A372428, zeros A372427.
For maximum instead of minimum we have A372442, zeros A372436.
For length instead of minimum we have A372441, zeros A071814.
A003963 gives product of prime indices.
A019565 gives Heinz number of binary indices, adjoint A048675.
A029837 gives greatest binary index, least A001511.
A048793 lists binary indices, length A000120, reverse A272020, sum A029931.
A061395 gives greatest prime index, least A055396.
A070939 gives length of binary expansion.
A112798 lists prime indices, length A001222, reverse A296150, sum A056239.

Programs

  • Mathematica
    bix[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    prix[n_]:=If[n==1,{},Flatten[Cases[FactorInteger[n],{p_,k_}:>Table[PrimePi[p],{k}]]]];
    Table[Min[bix[n]]-Min[prix[n]],{n,2,100}]

Formula

a(2n) = A001511(n).
a(2n + 1) = -A038802(n).
a(n) = A001511(n) - A055396(n).

A222955 Number of nX1 0..1 arrays with every row and column least squares fitting to a zero slope straight line, with a single point array taken as having zero slope.

Original entry on oeis.org

2, 2, 4, 4, 8, 8, 20, 18, 52, 48, 152, 138, 472, 428, 1520, 1392, 5044, 4652, 17112, 15884, 59008, 55124, 206260, 193724, 729096, 688008, 2601640, 2465134, 9358944, 8899700, 33904324, 32342236, 123580884, 118215780, 452902072, 434314138, 1667837680
Offset: 1

Views

Author

R. H. Hardin, Mar 10 2013

Keywords

Comments

Column 1 of A222959
Conjecture: A binary word is counted iff it has the same sum of positions of 1's as its reverse, or, equivalently, the same sum of partial sums as its reverse. - Gus Wiseman, Jan 07 2023

Examples

			All solutions for n=4
..0....1....1....0
..0....1....0....1
..0....1....0....1
..0....1....1....0
From _Gus Wiseman_, Jan 07 2023: (Start)
The a(1) = 2 through a(7) = 20 binary words with least squares fit a line of zero slope are:
  (0)  (00)  (000)  (0000)  (00000)  (000000)  (0000000)
  (1)  (11)  (010)  (0110)  (00100)  (001100)  (0001000)
             (101)  (1001)  (01010)  (010010)  (0010100)
             (111)  (1111)  (01110)  (011110)  (0011100)
                            (10001)  (100001)  (0100010)
                            (10101)  (101101)  (0101010)
                            (11011)  (110011)  (0110001)
                            (11111)  (111111)  (0110110)
                                               (0111001)
                                               (0111110)
                                               (1000001)
                                               (1000110)
                                               (1001001)
                                               (1001110)
                                               (1010101)
                                               (1011101)
                                               (1100011)
                                               (1101011)
                                               (1110111)
                                               (1111111)
(End)
		

Crossrefs

These words appear to be ranked by A359402.
A011782 counts compositions.
A359042 adds up partial sums of standard compositions, reversed A029931.

A359401 Nonnegative integers whose sum of positions of 1's in their binary expansion is greater than the sum of positions of 1's in their reversed binary expansion, where positions in a sequence are read starting with 1 from the left.

Original entry on oeis.org

11, 19, 23, 35, 37, 39, 43, 47, 55, 67, 69, 71, 75, 77, 79, 83, 87, 91, 95, 103, 111, 131, 133, 134, 135, 137, 139, 141, 142, 143, 147, 149, 151, 155, 157, 158, 159, 163, 167, 171, 173, 175, 179, 183, 187, 191, 199, 203, 207, 215, 223, 239, 259, 261, 262, 263
Offset: 1

Views

Author

Gus Wiseman, Jan 05 2023

Keywords

Comments

First differs from A161601 in having 134, with binary expansion (1,0,0,0,0,1,1,0), positions of 1's 1 + 6 + 7 = 14, reversed 2 + 3 + 8 = 13.

Crossrefs

Indices of positive terms in A359495; indices of 0's are A359402.
A030190 gives binary expansion, reverse A030308.
A070939 counts binary digits.
A230877 adds up positions of 1's in binary expansion, reverse A029931.
A326669 lists numbers with integer mean position of a 1 in binary expansion.

Programs

  • Mathematica
    sap[q_]:=Sum[q[[i]]*(2i-Length[q]-1),{i,Length[q]}];
    Select[Range[0,100],sap[IntegerDigits[#,2]]>0&]

Formula

A230877(a(n)) > A029931(a(n)).
Showing 1-10 of 14 results. Next