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

A048793 List giving all subsets of natural numbers arranged in standard statistical (or Yates) order.

Original entry on oeis.org

0, 1, 2, 1, 2, 3, 1, 3, 2, 3, 1, 2, 3, 4, 1, 4, 2, 4, 1, 2, 4, 3, 4, 1, 3, 4, 2, 3, 4, 1, 2, 3, 4, 5, 1, 5, 2, 5, 1, 2, 5, 3, 5, 1, 3, 5, 2, 3, 5, 1, 2, 3, 5, 4, 5, 1, 4, 5, 2, 4, 5, 1, 2, 4, 5, 3, 4, 5, 1, 3, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 6, 2, 6, 1, 2, 6, 3, 6, 1, 3, 6, 2, 3, 6, 1, 2, 3, 6, 4, 6, 1, 4
Offset: 0

Views

Author

Keywords

Comments

For n>0: first occurrence of n in row 2^(n-1), and when the table is seen as a flattened list at position n*2^(n-1)+1, cf. A005183. - Reinhard Zumkeller, Nov 16 2013
Row n lists the positions of 1's in the reversed binary expansion of n. Compare to triangles A112798 and A213925. - Gus Wiseman, Jul 22 2019

Examples

			From _Gus Wiseman_, Jul 22 2019: (Start)
Triangle begins:
  {}
  1
  2
  1  2
  3
  1  3
  2  3
  1  2  3
  4
  1  4
  2  4
  1  2  4
  3  4
  1  3  4
  2  3  4
  1  2  3  4
  5
  1  5
  2  5
  1  2  5
  3  5
(End)
		

References

  • S. Hedayat, N. J. A. Sloane and J. Stufken, Orthogonal Arrays, Springer-Verlag, NY, 1999, p. 249.

Crossrefs

Cf. A048794.
Row lengths are A000120.
First column is A001511.
Heinz numbers of rows are A019565.
Row sums are A029931.
Reversing rows gives A272020.
Subtracting 1 from each term gives A133457; subtracting 1 and reversing rows gives A272011.
Indices of relatively prime rows are A291166 (see also A326674); arithmetic progressions are A295235; rows with integer average are A326669 (see also A326699/A326700); pairwise coprime rows are A326675.

Programs

  • C
    #include 
    #include 
    #define USAGE "Usage: 'A048793 num' where num is the largest number to use creating sets.\n"
    #define MAX_NUM 10
    #define MAX_ROW 1024
    int main(int argc, char *argv[]) {
      unsigned short a[MAX_ROW][MAX_NUM]; signed short old_row, new_row, i, j, end;
      if (argc < 2) { fprintf(stderr, USAGE); return EXIT_FAILURE; }
      end = atoi(argv[1]); end = (end > MAX_NUM) ? MAX_NUM: end;
      for (i = 0; i < MAX_ROW; i++) for ( j = 0; j < MAX_NUM; j++) a[i][j] = 0;
      a[1][0] = 1; new_row = 2;
      for (i = 2; i <= end; i++) {
        a[new_row++ ][0] = i;
        for (old_row = 1; a[old_row][0] != i; old_row++) {
          for (j = 0; a[old_row][j] != 0; j++) { a[new_row][j] = a[old_row][j]; }
          a[new_row++ ][j] = i;
        }
      }
      fprintf(stdout, "Values: 0");
      for (i = 1; a[i][0] != 0; i++) for (j = 0; a[i][j] != 0; j++) fprintf(stdout, ",%d", a[i][j]);
      fprintf(stdout, "\n"); return EXIT_SUCCESS
    }
    
  • Haskell
    a048793 n k = a048793_tabf !! n !! k
    a048793_row n = a048793_tabf !! n
    a048793_tabf = [0] : [1] : f [[1]] where
       f xss = yss ++ f (xss ++ yss) where
         yss = [y] : map (++ [y]) xss
         y = last (last xss) + 1
    -- Reinhard Zumkeller, Nov 16 2013
  • Maple
    T:= proc(n) local i, l, m; l:= NULL; m:= n;
          if n=0 then return 0 fi; for i while m>0 do
          if irem(m, 2, 'm')=1 then l:=l, i fi od; l
        end:
    seq(T(n), n=0..50);  # Alois P. Heinz, Sep 06 2014
  • Mathematica
    s[0] = {{}}; s[n_] := s[n] = Join[s[n - 1], Append[#, n]& /@ s[n - 1]]; Join[{0}, Flatten[s[6]]] (* Jean-François Alcover, May 24 2012 *)
    Table[Join@@Position[Reverse[IntegerDigits[n,2]],1],{n,30}] (* Gus Wiseman, Jul 22 2019 *)

Formula

Constructed recursively: subsets that include n are obtained by appending n to all earlier subsets.

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Apr 11 2000

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

A096111 If n = 2^k - 1, then a(n) = k+1, otherwise a(n) = (A000523(n)+1)*a(A053645(n)).

Original entry on oeis.org

1, 2, 2, 3, 3, 6, 6, 4, 4, 8, 8, 12, 12, 24, 24, 5, 5, 10, 10, 15, 15, 30, 30, 20, 20, 40, 40, 60, 60, 120, 120, 6, 6, 12, 12, 18, 18, 36, 36, 24, 24, 48, 48, 72, 72, 144, 144, 30, 30, 60, 60, 90, 90, 180, 180, 120, 120, 240, 240, 360, 360, 720, 720, 7, 7, 14, 14, 21, 21
Offset: 0

Views

Author

Amarnath Murthy, Jun 29 2004

Keywords

Comments

Each n > 1 occurs 2*A045778(n) times in the sequence.
f(n+2^k) = (k+1)*f(n) if 2^k > n+1. - Robert Israel, Apr 25 2016
If the binary indices of n (row n of A048793) are the positions 1's in its reversed binary expansion, then a(n) is the product of all binary indices of n + 1. The number of binary indices of n is A000120(n), their sum is A029931(n), and their average is A326699(n)/A326700(n). - Gus Wiseman, Jul 27 2019

Crossrefs

Permutation of A096115, i.e. a(n) = A096115(A122198(n+1)) [Note the different starting offsets]. Bisection: A121663. Cf. A096113, A052330.
Cf. A029931.

Programs

  • Maple
    f:= proc(n) local L;
        L:= convert(2*n+2,base,2);
        convert(subs(0=NULL,zip(`*`,L, [$0..nops(L)-1])),`*`);
    end proc:
    map(f, [$0..100]); # Robert Israel, Apr 25 2016
  • Mathematica
    CoefficientList[(Product[1 + k x^(2^(k - 1)), {k, 7}] - 1)/x, x] (* Michael De Vlieger, Apr 08 2016 *)
    bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];Table[Times@@bpe[n+1],{n,0,100}] (* Gus Wiseman, Jul 26 2019 *)
  • PARI
    N=166; q='q+O('q^N);
    gf= (prod(n=1,1+ceil(log(N)/log(2)), 1+n*q^(2^(n-1)) ) - 1) / q;
    Vec(gf)
    /* Joerg Arndt, Oct 06 2012 */
  • Scheme
    (define (A096111 n) (cond ((pow2? (+ n 1)) (+ 2 (A000523 n))) (else (* (+ 1 (A000523 n)) (A096111 (A053645 n))))))
    (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))
    

Formula

G.f.: ( prod(k>=1, 1+k*x^(2^(k-1)) )- 1 ) / x. - Vladeta Jovovic, Nov 08 2005
a(n) is the product of the exponents in the binary expansion of 2*n + 2. - Peter Kagey, Apr 24 2016

Extensions

Edited, extended and Scheme code added by Antti Karttunen, Aug 25 2006

A326699 Numerator of the average position of a 1 in the reversed binary expansion of n.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jul 20 2019

Keywords

Examples

			The sequence of fractions begins: 1, 2, 3/2, 3, 2, 5/2, 2, 4, 5/2, 3, 7/3, 7/2, 8/3, 3, 5/2, 5, 3, 7/2, 8/3, 4.
For example, the reversed binary expansion of 18 is (0,1,0,0,1), and the average of {2,5} is 7/2, so a(18) = 7.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L;
      L:= convert(n,base,2);
      L:= select(t -> L[t]=1, [$1..nops(L)]);
      numer(convert(L,`+`)/nops(L))
    end proc:
    map(f, [$1..100]); # Robert Israel, Oct 07 2019
  • Mathematica
    Table[Numerator[Mean[Join@@Position[Reverse[IntegerDigits[n,2]],1]]],{n,100}]

A327368 The positions of ones in the reversed binary expansion of n have integer mean and integer geometric mean.

Original entry on oeis.org

1, 2, 4, 8, 16, 32, 64, 128, 130, 256, 257, 512, 1024, 2048, 2084, 2316, 4096, 8192, 16384, 32768, 32776, 32777, 65536, 131072, 131074, 131200, 131457, 131462, 133390, 165920, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 8388640, 8388897, 8390688, 8519840
Offset: 1

Views

Author

Gus Wiseman, Sep 27 2019

Keywords

Examples

			The sequence of terms together with their binary indices begins:
  2      {2}
  4      {3}
  8      {4}
  16     {5}
  32     {6}
  64     {7}
  128    {8}
  130    {2,8}
  256    {9}
  257    {1,9}
  512    {10}
  1024   {11}
  2048   {12}
  2084   {3,6,12}
  2316   {3,4,9,12}
  4096   {13}
  8192   {14}
  16384  {15}
  32768  {16}
  32776  {4,16}
		

Crossrefs

A superset of A327777.
Numbers whose binary indices have integer mean: A326669
Numbers whose binary indices have integer geometric mean: A326673

Programs

  • Mathematica
    bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    Select[Range[1000],IntegerQ[Mean[bpe[#]]]&&IntegerQ[GeometricMean[bpe[#]]]&]
  • PARI
    ok(n)={my(s=0,p=1,k=0); for(i=0, logint(n,2), if(bittest(n,i), s+=i+1; p*=i+1; k++)); s%k==0 && ispower(p,k)}
    { for(n=1, 10^7, if(ok(n), print1(n, ", "))) } \\ Andrew Howroyd, Sep 29 2019

Extensions

a(33)-a(40) from Andrew Howroyd, Sep 29 2019

A327777 Prime numbers whose binary indices have integer mean and integer geometric mean.

Original entry on oeis.org

2, 257, 8519971, 36574494881, 140739702949921, 140773995710729, 140774004099109
Offset: 1

Views

Author

Gus Wiseman, Sep 27 2019

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.
Conjecture: This sequence is infinite.

Examples

			The initial terms together with their binary indices:
                2: {2}
              257: {1,9}
          8519971: {1,2,6,9,18,24}
      36574494881: {1,6,8,16,18,27,32,36}
  140739702949921: {1,6,12,27,32,48}
  140773995710729: {1,4,9,12,18,32,36,48}
  140774004099109: {1,3,6,12,18,24,32,36,48}
		

Crossrefs

A subset of A327368.
The binary weight of prime(n) is A014499(n), with binary length A035100(n).
Heinz numbers of partitions with integer mean: A316413.
Heinz numbers of partitions with integer geometric mean: A326623.
Heinz numbers with both: A326645.
Subsets with integer mean: A051293
Subsets with integer geometric mean: A326027
Subsets with both: A326643
Partitions with integer mean: A067538
Partitions with integer geometric mean: A067539
Partitions with both: A326641
Strict partitions with integer mean: A102627
Strict partitions with integer geometric mean: A326625
Strict partitions with both: A326029
Factorizations with integer mean: A326622
Factorizations with integer geometric mean: A326028
Factorizations with both: A326647
Numbers whose binary indices have integer mean: A326669
Numbers whose binary indices have integer geometric mean: A326673
Numbers whose binary indices have both: A327368

Programs

  • Mathematica
    bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    Select[Prime[Range[1000]],IntegerQ[Mean[bpe[#]]]&&IntegerQ[GeometricMean[bpe[#]]]&]

Extensions

a(4)-a(7) from Giovanni Resta, Dec 01 2019
Showing 1-6 of 6 results.