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 148 results. Next

A001227 Number of odd divisors of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Also (1) number of ways to write n as difference of two triangular numbers (A000217), see A136107; (2) number of ways to arrange n identical objects in a trapezoid. - Tom Verhoeff
Also number of partitions of n into consecutive positive integers including the trivial partition of length 1 (e.g., 9 = 2+3+4 or 4+5 or 9 so a(9)=3). (Useful for cribbage players.) See A069283. - Henry Bottomley, Apr 13 2000
This has been described as Sylvester's theorem, but to reduce ambiguity I suggest calling it Sylvester's enumeration. - Gus Wiseman, Oct 04 2022
a(n) is also the number of factors in the factorization of the Chebyshev polynomial of the first kind T_n(x). - Yuval Dekel (dekelyuval(AT)hotmail.com), Aug 28 2003
Number of factors in the factorization of the polynomial x^n+1 over the integers. See also A000005. - T. D. Noe, Apr 16 2003
a(n) = 1 if and only if n is a power of 2 (see A000079). - Lekraj Beedassy, Apr 12 2005
Number of occurrences of n in A049777. - Philippe Deléham, Jun 19 2005
For n odd, n is prime if and only if a(n) = 2. - George J. Schaeffer (gschaeff(AT)andrew.cmu.edu), Sep 10 2005
Also number of partitions of n such that if k is the largest part, then each of the parts 1,2,...,k-1 occurs exactly once. Example: a(9)=3 because we have [3,3,2,1],[2,2,2,2,1] and [1,1,1,1,1,1,1,1,1]. - Emeric Deutsch, Mar 07 2006
Also the number of factors of the n-th Lucas polynomial. - T. D. Noe, Mar 09 2006
Lengths of rows of triangle A182469;
Denoted by Delta_0(n) in Glaisher 1907. - Michael Somos, May 17 2013
Also the number of partitions p of n into distinct parts such that max(p) - min(p) < length(p). - Clark Kimberling, Apr 18 2014
Row sums of triangle A247795. - Reinhard Zumkeller, Sep 28 2014
Row sums of triangle A237048. - Omar E. Pol, Oct 24 2014
A069288(n) <= a(n). - Reinhard Zumkeller, Apr 05 2015
A000203, A000593 and this sequence have the same parity: A053866. - Omar E. Pol, May 14 2016
a(n) is equal to the number of ways to write 2*n-1 as (4*x + 2)*y + 4*x + 1 where x and y are nonnegative integers. Also a(n) is equal to the number of distinct values of k such that k/(2*n-1) + k divides (k/(2*n-1))^(k/(2*n-1)) + k, (k/(2*n-1))^k + k/(2*n-1) and k^(k/(2*n-1)) + k/(2*n-1). - Juri-Stepan Gerasimov, May 23 2016, Jul 15 2016
Also the number of odd divisors of n*2^m for m >= 0. - Juri-Stepan Gerasimov, Jul 15 2016
a(n) is odd if and only if n is a square or twice a square. - Juri-Stepan Gerasimov, Jul 17 2016
a(n) is also the number of subparts in the symmetric representation of sigma(n). For more information see A279387 and A237593. - Omar E. Pol, Nov 05 2016
a(n) is also the number of partitions of n into an odd number of equal parts. - Omar E. Pol, May 14 2017 [This follows from the g.f. Sum_{k >= 1} x^k/(1-x^(2*k)). - N. J. A. Sloane, Dec 03 2020]

Examples

			G.f. = q + q^2 + 2*q^3 + q^4 + 2*q^5 + 2*q^6 + 2*q^7 + q^8 + 3*q^9 + 2*q^10 + ...
From _Omar E. Pol_, Nov 30 2020: (Start)
For n = 9 there are three odd divisors of 9; they are [1, 3, 9]. On the other hand there are three partitions of 9 into consecutive parts: they are [9], [5, 4] and [4, 3, 2], so a(9) = 3.
Illustration of initial terms:
                              Diagram
   n   a(n)                         _
   1     1                        _|1|
   2     1                      _|1 _|
   3     2                    _|1  |1|
   4     1                  _|1   _| |
   5     2                _|1    |1 _|
   6     2              _|1     _| |1|
   7     2            _|1      |1  | |
   8     1          _|1       _|  _| |
   9     3        _|1        |1  |1 _|
  10     2      _|1         _|   | |1|
  11     2    _|1          |1   _| | |
  12     2   |1            |   |1  | |
...
a(n) is the number of horizontal line segments in the n-th level of the diagram. For more information see A286001. (End)
		

References

  • B. C. Berndt, Ramanujan's Notebooks Part V, Springer-Verlag, see p. 487 Entry 47.
  • L. E. Dickson, History of the Theory of Numbers. Carnegie Institute Public. 256, Washington, DC, Vol. 1, 1919; Vol. 2, 1920; Vol. 3, 1923, see vol. 1, p. 306.
  • J. W. L. Glaisher, On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares, Quart. J. Math. 38 (1907), 1-62 (see p. 4).
  • Ronald. L. Graham, Donald E. Knuth, and Oren Patashnik, Concrete Mathematics, 2nd ed. (Addison-Wesley, 1994), see exercise 2.30 on p. 65.
  • P. A. MacMahon, Combinatory Analysis, Cambridge Univ. Press, London and New York, Vol. 1, 1915 and Vol. 2, 1916; see vol. 2, p 28.

Crossrefs

If this sequence counts gapless sets by sum (by Sylvester's enumeration), these sets are ranked by A073485 and A356956. See also A055932, A066311, A073491, A107428, A137921, A333217, A356224, A356841, A356845.
Dirichlet inverse is A327276.

Programs

  • Haskell
    a001227 = sum . a247795_row
    -- Reinhard Zumkeller, Sep 28 2014, May 01 2012, Jul 25 2011
    
  • Magma
    [NumberOfDivisors(n)/Valuation(2*n, 2): n in [1..100]]; // Vincenzo Librandi, Jun 02 2019
    
  • Maple
    for n from 1 by 1 to 100 do s := 0: for d from 1 by 2 to n do if n mod d = 0 then s := s+1: fi: od: print(s); od:
    A001227 := proc(n) local a,d;
        a := 1 ;
        for d in ifactors(n)[2] do
            if op(1,d) > 2 then
                a := a*(op(2,d)+1) ;
            end if;
        end do:
        a ;
    end proc: # R. J. Mathar, Jun 18 2015
  • Mathematica
    f[n_] := Block[{d = Divisors[n]}, Count[ OddQ[d], True]]; Table[ f[n], {n, 105}] (* Robert G. Wilson v, Aug 27 2004 *)
    Table[Total[Mod[Divisors[n], 2]],{n,105}] (* Zak Seidov, Apr 16 2010 *)
    f[n_] := Block[{d = DivisorSigma[0, n]}, If[ OddQ@ n, d, d - DivisorSigma[0, n/2]]]; Array[f, 105] (* Robert G. Wilson v *)
    a[ n_] := Sum[  Mod[ d, 2], { d, Divisors[ n]}]; (* Michael Somos, May 17 2013 *)
    a[ n_] := DivisorSum[ n, Mod[ #, 2] &]; (* Michael Somos, May 17 2013 *)
    Count[Divisors[#],?OddQ]&/@Range[110] (* _Harvey P. Dale, Feb 15 2015 *)
    (* using a262045 from A262045 to compute a(n) = number of subparts in the symmetric representation of sigma(n) *)
    (* cl = current level, cs = current subparts count *)
    a001227[n_] := Module[{cs=0, cl=0, i, wL, k}, wL=a262045[n]; k=Length[wL]; For[i=1, i<=k, i++, If[wL[[i]]>cl, cs++; cl++]; If[wL[[i]]Hartmut F. W. Hoft, Dec 16 2016 *)
    a[n_] := DivisorSigma[0, n / 2^IntegerExponent[n, 2]]; Array[a, 100] (* Amiram Eldar, Jun 12 2022 *)
  • PARI
    {a(n) = sumdiv(n, d, d%2)}; /* Michael Somos, Oct 06 2007 */
    
  • PARI
    {a(n) = direuler( p=2, n, 1 / (1 - X) / (1 - kronecker( 4, p) * X))[n]}; /* Michael Somos, Oct 06 2007 */
    
  • PARI
    a(n)=numdiv(n>>valuation(n,2)) \\ Charles R Greathouse IV, Mar 16 2011
    
  • PARI
    a(n)=sum(k=1,round(solve(x=1,n,x*(x+1)/2-n)),(k^2-k+2*n)%(2*k)==0) \\ Charles R Greathouse IV, May 31 2013
    
  • PARI
    a(n)=sumdivmult(n,d,d%2) \\ Charles R Greathouse IV, Aug 29 2013
    
  • Python
    from functools import reduce
    from operator import mul
    from sympy import factorint
    def A001227(n): return reduce(mul,(q+1 for p, q in factorint(n).items() if p > 2),1) # Chai Wah Wu, Mar 08 2021
  • SageMath
    def A001227(n): return len([1 for d in divisors(n) if is_odd(d)])
    [A001227(n) for n in (1..80)]  # Peter Luschny, Feb 01 2012
    

Formula

Dirichlet g.f.: zeta(s)^2*(1-1/2^s).
Comment from N. J. A. Sloane, Dec 02 2020: (Start)
By counting the odd divisors f n in different ways, we get three different ways of writing the ordinary generating function. It is:
A(x) = x + x^2 + 2*x^3 + x^4 + 2*x^5 + 2*x^6 + 2*x^7 + x^8 + 3*x^9 + 2*x^10 + ...
= Sum_{k >= 1} x^(2*k-1)/(1-x^(2*k-1))
= Sum_{k >= 1} x^k/(1-x^(2*k))
= Sum_{k >= 1} x^(k*(k+1)/2)/(1-x^k) [Ramanujan, 2nd notebook, p. 355.].
(This incorporates comments from Vladeta Jovovic, Oct 16 2002 and Michael Somos, Oct 30 2005.) (End)
G.f.: x/(1-x) + Sum_{n>=1} x^(3*n)/(1-x^(2*n)), also L(x)-L(x^2) where L(x) = Sum_{n>=1} x^n/(1-x^n). - Joerg Arndt, Nov 06 2010
a(n) = A000005(n)/(A007814(n)+1) = A000005(n)/A001511(n).
Multiplicative with a(p^e) = 1 if p = 2; e+1 if p > 2. - David W. Wilson, Aug 01 2001
a(n) = A000005(A000265(n)). - Lekraj Beedassy, Jan 07 2005
Moebius transform is period 2 sequence [1, 0, ...] = A000035, which means a(n) is the Dirichlet convolution of A000035 and A057427.
a(n) = A113414(2*n). - N. J. A. Sloane, Jan 24 2006 (corrected Nov 10 2007)
a(n) = A001826(n) + A001842(n). - Reinhard Zumkeller, Apr 18 2006
Sequence = M*V = A115369 * A000005, where M = an infinite lower triangular matrix and V = A000005, d(n); as a vector: [1, 2, 2, 3, 2, 4, ...]. - Gary W. Adamson, Apr 15 2007
Equals A051731 * [1,0,1,0,1,...]; where A051731 is the inverse Mobius transform. - Gary W. Adamson, Nov 06 2007
a(n) = A000005(n) - A183063(n).
a(n) = d(n) if n is odd, or d(n) - d(n/2) if n is even, where d(n) is the number of divisors of n (A000005). (See the Weisstein page.) - Gary W. Adamson, Mar 15 2011
Dirichlet convolution of A000005 and A154955 (interpreted as a flat sequence). - R. J. Mathar, Jun 28 2011
a(A000079(n)) = 1; a(A057716(n)) > 1; a(A093641(n)) <= 2; a(A038550(n)) = 2; a(A105441(n)) > 2; a(A072502(n)) = 3. - Reinhard Zumkeller, May 01 2012
a(n) = 1 + A069283(n). - R. J. Mathar, Jun 18 2015
a(A002110(n)/2) = n, n >= 1. - Altug Alkan, Sep 29 2015
a(n*2^m) = a(n*2^i), a((2*j+1)^n) = n+1 for m >= 0, i >= 0 and j >= 0. a((2*x+1)^n) = a((2*y+1)^n) for positive x and y. - Juri-Stepan Gerasimov, Jul 17 2016
Conjectures: a(n) = A067742(n) + 2*A131576(n) = A082647(n) + A131576(n). - Omar E. Pol, Feb 15 2017
a(n) = A000005(2n) - A000005(n) = A099777(n)-A000005(n). - Danny Rorabaugh, Oct 03 2017
L.g.f.: -log(Product_{k>=1} (1 - x^(2*k-1))^(1/(2*k-1))) = Sum_{n>=1} a(n)*x^n/n. - Ilya Gutkovskiy, Jul 30 2018
G.f.: (psi_{q^2}(1/2) + log(1-q^2))/log(q), where psi_q(z) is the q-digamma function. - Michael Somos, Jun 01 2019
a(n) = A003056(n) - A238005(n). - Omar E. Pol, Sep 12 2021
Sum_{k=1..n} a(k) ~ n*log(n)/2 + (gamma + log(2)/2 - 1/2)*n, where gamma is Euler's constant (A001620). - Amiram Eldar, Nov 27 2022
Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k)/A000005(k) = log(2) (A002162). - Amiram Eldar, Mar 01 2023
a(n) = Sum_{i=1..n} (-1)^(i+1)*A135539(n,i). - Ridouane Oudra, Apr 13 2023

A333489 Numbers k such that the k-th composition in standard order is an anti-run (no adjacent equal parts).

Original entry on oeis.org

0, 1, 2, 4, 5, 6, 8, 9, 12, 13, 16, 17, 18, 20, 22, 24, 25, 32, 33, 34, 37, 38, 40, 41, 44, 45, 48, 49, 50, 52, 54, 64, 65, 66, 68, 69, 70, 72, 76, 77, 80, 81, 82, 88, 89, 96, 97, 98, 101, 102, 104, 105, 108, 109, 128, 129, 130, 132, 133, 134, 137, 140, 141
Offset: 1

Views

Author

Gus Wiseman, Mar 28 2020

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n. The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again.

Examples

			The sequence together with the corresponding compositions begins:
    0: ()          33: (5,1)         70: (4,1,2)
    1: (1)         34: (4,2)         72: (3,4)
    2: (2)         37: (3,2,1)       76: (3,1,3)
    4: (3)         38: (3,1,2)       77: (3,1,2,1)
    5: (2,1)       40: (2,4)         80: (2,5)
    6: (1,2)       41: (2,3,1)       81: (2,4,1)
    8: (4)         44: (2,1,3)       82: (2,3,2)
    9: (3,1)       45: (2,1,2,1)     88: (2,1,4)
   12: (1,3)       48: (1,5)         89: (2,1,3,1)
   13: (1,2,1)     49: (1,4,1)       96: (1,6)
   16: (5)         50: (1,3,2)       97: (1,5,1)
   17: (4,1)       52: (1,2,3)       98: (1,4,2)
   18: (3,2)       54: (1,2,1,2)    101: (1,3,2,1)
   20: (2,3)       64: (7)          102: (1,3,1,2)
   22: (2,1,2)     65: (6,1)        104: (1,2,4)
   24: (1,4)       66: (5,2)        105: (1,2,3,1)
   25: (1,3,1)     68: (4,3)        108: (1,2,1,3)
   32: (6)         69: (4,2,1)      109: (1,2,1,2,1)
		

Crossrefs

Anti-runs summing to n are counted by A003242(n).
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279 or A238130.
Partitions whose first differences are an anti-run are A238424.
All of the following pertain to compositions in standard order (A066099):
- Adjacent equal pairs are counted by A124762.
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are ranked by A233564.
- Constant compositions are ranked by A272919.
- Normal compositions are ranked by A333217.
- Anti-runs are counted by A333381.
- Adjacent unequal pairs are counted by A333382.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Select[Range[0,100],!MatchQ[stc[#],{_,x_,x_,_}]&]

A124767 Number of level runs for compositions in standard order.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The standard order of compositions is given by A066099.
For n > 0, a(n) is one more than the number of adjacent unequal terms in the n-th composition in standard order. Also the number of runs in the same composition. - Gus Wiseman, Apr 08 2020

Examples

			Composition number 11 is 2,1,1; the level runs are 2; 1,1; so a(11) = 2.
The table starts:
  0
  1
  1 1
  1 2 2 1
  1 2 1 2 2 3 2 1
  1 2 2 2 2 2 3 2 2 3 2 3 2 3 2 1
  1 2 2 2 1 3 3 2 2 3 1 2 3 4 3 2 2 3 3 3 3 3 4 3 2 3 2 3 2 3 2 1
The 1234567th composition in standard order is (3,2,1,2,2,1,2,5,1,1,1) with runs ((3),(2),(1),(2,2),(1),(2),(5),(1,1,1)), so a(1234567) = 8. - _Gus Wiseman_, Apr 08 2020
		

Crossrefs

Row-lengths are A011782.
Compositions counted by number of runs are A238279 or A333755.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Sum is A070939.
- Weakly decreasing compositions are A114994.
- Adjacent equal pairs are counted by A124762.
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767 (this sequence).
- Weakly increasing compositions are A225620.
- Strict compositions A233564.
- Constant compositions are A272919.
- Anti-runs are counted by A333381.
- Adjacent unequal pairs are counted by A333382.
- Anti-run compositions are A333489.
- Runs-resistance is A333628.
- Run-lengths are A333769 (triangle).

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Table[Length[Split[stc[n]]],{n,0,100}] (* Gus Wiseman, Apr 17 2020 *)

Formula

a(0) = 0, a(n) = 1 + Sum_{1<=i=1 0.
For n > 0, a(n) = A333382(n) + 1. - Gus Wiseman, Apr 08 2020

A233564 c-squarefree numbers: positive integers which in binary are concatenation of distinct parts of the form 10...0 with nonnegative number of zeros.

Original entry on oeis.org

0, 1, 2, 4, 5, 6, 8, 9, 12, 16, 17, 18, 20, 24, 32, 33, 34, 37, 38, 40, 41, 44, 48, 50, 52, 64, 65, 66, 68, 69, 70, 72, 80, 81, 88, 96, 98, 104, 128, 129, 130, 132, 133, 134, 137, 140, 144, 145, 152, 160, 161, 176, 192, 194, 196, 200, 208, 256, 257, 258, 260, 261
Offset: 1

Views

Author

Vladimir Shevelev, Dec 13 2013

Keywords

Comments

Number of terms in interval [2^(n-1), 2^n) is the number of compositions of n with distinct parts (cf. A032020). For example, if n=6, then interval [2^5, 2^6) contains 11 terms {32,...,52}. This corresponds to 11 compositions with distinct parts of 6: 6, 5+1, 1+5, 4+2, 2+4, 3+2+1, 3+1+2, 2+3+1, 2+1+3, 1+3+2, 1+2+3.
From Gus Wiseman, Apr 06 2020: (Start)
The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions. This sequence lists all numbers k such that the k-th composition in standard order is strict. For example, the sequence together with the corresponding strict compositions begins:
0: () 38: (3,1,2) 98: (1,4,2)
1: (1) 40: (2,4) 104: (1,2,4)
2: (2) 41: (2,3,1) 128: (8)
4: (3) 44: (2,1,3) 129: (7,1)
5: (2,1) 48: (1,5) 130: (6,2)
6: (1,2) 50: (1,3,2) 132: (5,3)
8: (4) 52: (1,2,3) 133: (5,2,1)
9: (3,1) 64: (7) 134: (5,1,2)
12: (1,3) 65: (6,1) 137: (4,3,1)
16: (5) 66: (5,2) 140: (4,1,3)
17: (4,1) 68: (4,3) 144: (3,5)
18: (3,2) 69: (4,2,1) 145: (3,4,1)
20: (2,3) 70: (4,1,2) 152: (3,1,4)
24: (1,4) 72: (3,4) 160: (2,6)
32: (6) 80: (2,5) 161: (2,5,1)
33: (5,1) 81: (2,4,1) 176: (2,1,5)
34: (4,2) 88: (2,1,4) 192: (1,7)
37: (3,2,1) 96: (1,6) 194: (1,5,2)
(End)

Examples

			49 in binary has the following parts of the form 10...0 with nonnegative number of  zeros: (1),(1000),(1). Two of them are the same. So it is not in the sequence. On the other hand, 50 has distinct parts (1)(100)(10), thus it is a term.
		

Crossrefs

A subset of A333489 and superset of A333218.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Weighted sum is A029931.
- Partial sums from the right are A048793.
- Sum is A070939.
- Runs are counted by A124767.
- Reversed initial intervals A164894.
- Initial intervals are A246534.
- Constant compositions are A272919.
- Strictly decreasing compositions are A333255.
- Strictly increasing compositions are A333256.
- Anti-runs are counted by A333381.
- Anti-runs are A333489.

Programs

  • Mathematica
    bitPatt[n_]:=bitPatt[n]=Split[IntegerDigits[n,2],#1>#2||#2==0&];
    Select[Range[0,300],bitPatt[#]==DeleteDuplicates[bitPatt[#]]&] (* Peter J. C. Moses, Dec 13 2013 *)
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Select[Range[0,100],UnsameQ@@stc[#]&] (* Gus Wiseman, Apr 04 2020 *)

Extensions

More terms from Peter J. C. Moses, Dec 13 2013
0 prepended by Gus Wiseman, Apr 04 2020

A228351 Triangle read by rows in which row n lists the compositions (ordered partitions) of n (see Comments lines for definition).

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Aug 30 2013

Keywords

Comments

The representation of the compositions (for fixed n) is as lists of parts, the order between individual compositions (for the same n) is (list-)reversed co-lexicographic. - Joerg Arndt, Sep 02 2013
Dropping the "(list-)reversed" in the comment above gives A228525.
The equivalent sequence for partitions is A026792.
This sequence lists (without repetitions) all finite compositions, in such a way that, if [P_1, ..., P_r] denotes the composition occupying the n-th position in the list, then (((2*n/2^(P_1)-1)/2^(P_2)-1)/...)/2^(P_r)-1 = 0. - Lorenzo Sauras Altuzarra, Jan 22 2020
The k-th composition in the list is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, and taking first differences. Reversing again gives A066099, which is described as the standard ordering. Both sequences define a bijective correspondence between nonnegative integers and integer compositions. - Gus Wiseman, Apr 01 2020
It follows from the previous comment that A000120(k) is the length of the k-th composition that is listed by this sequence (recall that A000120(k) is the number of 1's in the binary expansion of k). - Lorenzo Sauras Altuzarra, Sep 29 2020

Examples

			Illustration of initial terms:
-----------------------------------
n  j     Diagram     Composition j
-----------------------------------
.         _
1  1     |_|         1;
.         _ _
2  1     |_  |       2,
2  2     |_|_|       1, 1;
.         _ _ _
3  1     |_    |     3,
3  2     |_|_  |     1, 2,
3  3     |_  | |     2, 1,
3  4     |_|_|_|     1, 1, 1;
.         _ _ _ _
4  1     |_      |   4,
4  2     |_|_    |   1, 3,
4  3     |_  |   |   2, 2,
4  4     |_|_|_  |   1, 1, 2,
4  5     |_    | |   3, 1,
4  6     |_|_  | |   1, 2, 1,
4  7     |_  | | |   2, 1, 1,
4  8     |_|_|_|_|   1, 1, 1, 1;
.
Triangle begins:
[1];
[2],[1,1];
[3],[1,2],[2,1],[1,1,1];
[4],[1,3],[2,2],[1,1,2],[3,1],[1,2,1],[2,1,1],[1,1,1,1];
[5],[1,4],[2,3],[1,1,3],[3,2],[1,2,2],[2,1,2],[1,1,1,2],[4,1],[1,3,1],[2,2,1],[1,1,2,1],[3,1,1],[1,2,1,1],[2,1,1,1],[1,1,1,1,1];
...
For example [1,2] occupies the 5th position in the corresponding list of compositions and indeed (2*5/2^1-1)/2^2-1 = 0. - _Lorenzo Sauras Altuzarra_, Jan 22 2020
12 --binary expansion--> [1,1,0,0] --reverse--> [0,0,1,1] --positions of 1's--> [3,4] --prepend 0--> [0,3,4] --first differences--> [3,1]. - _Lorenzo Sauras Altuzarra_, Sep 29 2020
		

Crossrefs

Row n has length A001792(n-1). Row sums give A001787, n >= 1.
Cf. A000120 (binary weight), A001511, A006519, A011782, A026792, A065120.
A related ranking of finite sets is A048793/A272020.
All of the following consider the k-th row to be the k-th composition, ignoring the coarser grouping by sum.
- Indices of weakly increasing rows are A114994.
- Indices of weakly decreasing rows are A225620.
- Indices of strictly decreasing rows are A333255.
- Indices of strictly increasing rows are A333256.
- Indices of reversed interval rows A164894.
- Indices of interval rows are A246534.
- Indices of strict rows are A233564.
- Indices of constant rows are A272919.
- Indices of anti-run rows are A333489.
- Row k has A124767(k) runs and A333381(k) anti-runs.
- Row k has GCD A326674(k) and LCM A333226(k).
- Row k has Heinz number A333219(k).
Equals A163510+1, termwise.
Cf. A124734 (increasing length, then lexicographic).
Cf. A296774 (increasing length, then reverse lexicographic).
Cf. A337243 (increasing length, then colexicographic).
Cf. A337259 (increasing length, then reverse colexicographic).
Cf. A296773 (decreasing length, then lexicographic).
Cf. A296772 (decreasing length, then reverse lexicographic).
Cf. A337260 (decreasing length, then colexicographic).
Cf. A108244 (decreasing length, then reverse colexicographic).
Cf. A228369 (lexicographic).
Cf. A066099 (reverse lexicographic).
Cf. A228525 (colexicographic).

Programs

  • Haskell
    a228351 n = a228351_list !! (n - 1)
    a228351_list = concatMap a228351_row [1..]
    a228351_row 0 = []
    a228351_row n = a001511 n : a228351_row (n `div` 2^(a001511 n))
    -- Peter Kagey, Jun 27 2016
    
  • Maple
    # Program computing the sequence:
    A228351 := proc(n) local c, k, L, N: L, N := [], [seq(2*r, r = 1 .. n)]: for k in N do c := 0: while k != 0 do if gcd(k, 2) = 2 then k := k/2: c := c+1: else L := [op(L), op(c)]: k := k-1: c := 0: fi: od: od: L[n]: end: # Lorenzo Sauras Altuzarra, Jan 22 2020
    # Program computing the list of compositions:
    List := proc(n) local c, k, L, M, N: L, M, N := [], [], [seq(2*r, r = 1 .. 2^n-1)]: for k in N do c := 0: while k != 0 do if gcd(k, 2) = 2 then k := k/2: c := c+1: else L := [op(L), c]: k := k-1: c := 0: fi: od: M := [op(M), L]: L := []: od: M: end: # Lorenzo Sauras Altuzarra, Jan 22 2020
  • Mathematica
    bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    Table[Differences[Prepend[bpe[n],0]],{n,0,30}] (* Gus Wiseman, Apr 01 2020 *)
  • Python
    from itertools import count, islice
    def A228351_gen(): # generator of terms
        for n in count(1):
            k = n
            while k:
                yield (s:=(~k&k-1).bit_length()+1)
                k >>= s
    A228351_list = list(islice(A228351_gen(),30)) # Chai Wah Wu, Jul 17 2023

A333381 Number of maximal anti-runs of the n-th composition in standard order.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Mar 24 2020

Keywords

Comments

Anti-runs are sequences without any adjacent equal terms.
A composition of n is a finite sequence of positive integers summing to n. The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again.
For n > 0, also one plus the number of adjacent equal pairs in the n-th composition in standard order.

Examples

			The 46th composition in standard order is (2,1,1,2), with maximal anti-runs ((2,1),(1,2)), so a(46) = 2.
		

Crossrefs

Anti-runs summing to n are counted by A003242(n).
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279.
Partitions whose first differences are an anti-run are A238424.
All of the following pertain to compositions in standard order (A066099):
- Adjacent equal pairs are counted by A124762.
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are ranked by A233564.
- Constant compositions are ranked by A272919.
- Normal compositions are ranked by A333217.
- Adjacent unequal pairs are counted by A333382.
- Anti-runs are ranked by A333489.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Table[Length[Split[stc[n],UnsameQ]],{n,0,100}]

Formula

For n > 0, a(n) = A124762(n) + 1.

A102726 Number of compositions of the integer n into positive parts that avoid a fixed pattern of three letters.

Original entry on oeis.org

1, 1, 2, 4, 8, 16, 31, 60, 114, 214, 398, 732, 1334, 2410, 4321, 7688, 13590, 23869, 41686, 72405, 125144, 215286, 368778, 629156, 1069396, 1811336, 3058130, 5147484, 8639976, 14463901, 24154348, 40244877, 66911558, 111026746, 183886685, 304034456, 501877227
Offset: 0

Views

Author

Herbert S. Wilf, Feb 07 2005

Keywords

Comments

The sequence is the same no matter which of the six patterns of three letters is chosen as the one to be avoided.

Examples

			a(6) = 31 because there are 32 compositions of 6 into positive parts and only one of these, namely 6 = 1+2+3, contains the pattern (123), the other 31 compositions of 6 avoid that pattern.
		

Crossrefs

The version for patterns is A226316.
These compositions are ranked by the complement of A335479.
The matching version is A335514.
The version for prime indices is A335521.
Constant patterns are counted by A000005 and ranked by A272919.
Permutations are counted by A000142 and ranked by A333218.
Patterns are counted by A000670 and ranked by A333217.
Compositions are counted by A011782.
Strict compositions are counted by A032020 and ranked by A233564.
Patterns matched by compositions are counted by A335456.
Minimal patterns avoided by a given composition are counted by A335465.

Programs

  • Maple
    b:= proc(n, m, t) option remember; `if`(n=0, 1,
          add(b(n-i, min(m, i, n-i), min(t, n-i,
          `if`(i>m, i, t))), i=1..min(n, t)))
        end:
    a:= n-> b(n$3):
    seq(a(n), n=0..50);  # Alois P. Heinz, Mar 18 2014
  • Mathematica
    b[n_, m_, t_] := b[n, m, t] = If[n == 0, 1, Sum[b[n - i, Min[m, i, n - i], Min[t, n - i, If[i > m, i, t]]], {i, 1, Min[n, t]}]];
    a[n_] := b[n, n, n];
    Table[a[n], {n, 0, 50}] (* Jean-François Alcover, Nov 10 2017, after Alois P. Heinz *)
    mstype[q_]:=q/.Table[Union[q][[i]]->i,{i,Length[Union[q]]}];
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],!MemberQ[Union[mstype/@Subsets[#]],{1,2,3}]&]],{n,0,10}] (* Gus Wiseman, Jun 22 2020 *)
  • PARI
    seq(n)={Vec(sum(i=1, n, prod(j=1, n, if(i==j, 1, (1-x^i)/((1-x^(j-i))*(1-x^i-x^j))) + O(x*x^n))/(1-x^i)))} \\ Andrew Howroyd, Dec 31 2020

Formula

G.f.: Sum_{i>=1} (1/(1-x^i))*Product_{j>=1, j<>i} (1-x^i)/((1-x^(j-i))*(1-x^i-x^j)).
Asymptotics (Savage and Wilf, 2005): a(n) ~ c * ((1+sqrt(5))/2)^n, where c = r/(r-1)/(r-s) * (r * Product_{j>=3} (1-1/r)/(1-r^(1-j))/(1-1/r-r^(-j)) - Product_{j>=3} (1-1/r^2)/(1-r^(2-j))/(1-1/r^2-r^(-j)) ) = 18.9399867283479198666671671745270505487677312850521421513193261105... and r = (1+sqrt(5))/2, s = (1-sqrt(5))/2. - Vaclav Kotesovec, May 02 2014

Extensions

More terms from Ralf Stephan, May 27 2005

A335456 Number of normal patterns matched by compositions of n.

Original entry on oeis.org

1, 2, 5, 12, 32, 84, 211, 556, 1446, 3750, 9824, 25837, 67681, 178160, 468941, 1233837, 3248788, 8554709
Offset: 0

Views

Author

Gus Wiseman, Jun 16 2020

Keywords

Comments

A composition of n is a finite sequence of positive integers summing to n.
We define a pattern to be a finite sequence covering an initial interval of positive integers. Patterns are counted by A000670 and ranked by A333217. A sequence S is said to match a pattern P if there is a not necessarily contiguous subsequence of S whose parts have the same relative order as P. For example, (3,1,1,3) matches (1,1,2), (2,1,1), and (2,1,2), but avoids (1,2,1), (1,2,2), and (2,2,1).

Examples

			The 8 compositions of 4 together with the a(4) = 32 patterns they match:
  4:   31:   13:   22:   211:   121:   112:   1111:
-----------------------------------------------------
  ()   ()    ()    ()    ()     ()     ()     ()
  (1)  (1)   (1)   (1)   (1)    (1)    (1)    (1)
       (21)  (12)  (11)  (11)   (11)   (11)   (11)
                         (21)   (12)   (12)   (111)
                         (211)  (21)   (112)  (1111)
                                (121)
		

Crossrefs

References found in the link are not all included here.
The version for standard compositions is A335454.
The contiguous case is A335457.
The version for Heinz numbers of partitions is A335549.
Patterns are counted by A000670 and ranked by A333217.
The n-th composition has A124771(n) distinct consecutive subsequences.
Knapsack compositions are counted by A325676 and ranked by A333223.
The n-th composition has A333257(n) distinct subsequence-sums.
The n-th composition has A334299(n) distinct subsequences.
Minimal patterns avoided by a standard composition are counted by A335465.

Programs

  • Mathematica
    mstype[q_]:=q/.Table[Union[q][[i]]->i,{i,Length[Union[q]]}];
    Table[Sum[Length[Union[mstype/@Subsets[y]]],{y,Join@@Permutations/@IntegerPartitions[n]}],{n,0,8}]

Extensions

a(14)-a(16) from Jinyuan Wang, Jun 26 2020
a(17) from John Tyler Rascoe, Mar 14 2025

A124762 Number of levels for compositions in standard order.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The standard order of compositions is given by A066099.
A composition of n is a finite sequence of positive integers summing to n. The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions. This sequence gives the number of adjacent equal terms in the n-th composition in standard order. Alternatively, a(n) is one fewer than the number of maximal anti-runs in the same composition, where anti-runs are sequences without any adjacent equal terms. For example, the 1234567th composition in standard order is (3,2,1,2,2,1,2,5,1,1,1) with anti-runs ((3,2,1,2),(2,1,2,5,1),(1),(1)), so a(1234567) = 4 - 1 = 3. - Gus Wiseman, Apr 08 2020

Examples

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

Crossrefs

Cf. A066099, A124760, A124761, A124763, A124764, A011782 (row lengths), A059570 (row sums).
Anti-runs summing to n are counted by A003242(n).
A triangle counting maximal anti-runs of compositions is A106356.
A triangle counting maximal runs of compositions is A238279.
Partitions whose first differences are an anti-run are A238424.
All of the following pertain to compositions in standard order (A066099):
- Weakly decreasing runs are counted by A124765.
- Weakly increasing runs are counted by A124766.
- Equal runs are counted by A124767.
- Strictly increasing runs are counted by A124768.
- Strictly decreasing runs are counted by A124769.
- Strict compositions are A233564.
- Constant compositions are A272919.
- Normal compositions are A333217.
- Adjacent unequal pairs are counted by A333382.
- Anti-runs are A333489.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Table[Length[Select[Partition[stc[n],2,1],SameQ@@#&]],{n,0,100}] (* Gus Wiseman, Apr 08 2020 *)

Formula

For a composition b(1),...,b(k), a(n) = Sum_{1<=i=1
For n > 0, a(n) = A333381(n) - 1. - Gus Wiseman, Apr 08 2020

A225620 Indices of partitions in the table of compositions of A228351.

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 8, 10, 12, 14, 15, 16, 20, 24, 26, 28, 30, 31, 32, 36, 40, 42, 48, 52, 56, 58, 60, 62, 63, 64, 72, 80, 84, 96, 100, 104, 106, 112, 116, 120, 122, 124, 126, 127, 128, 136, 144, 160, 164, 168, 170, 192, 200, 208, 212, 224, 228, 232, 234, 240, 244, 248, 250, 252, 254, 255
Offset: 1

Author

Omar E. Pol, Aug 03 2013

Keywords

Comments

Also triangle read by rows in which T(n,k) is the decimal representation of a binary number whose mirror represents the k-th partition of n according with the list of juxtaposed reverse-lexicographically ordered partitions of the positive integers (A026792).
In order to construct this sequence as a triangle we use the following rules:
- In the list of A026792 we replace each part of size j of the k-th partition of n by concatenation of j - 1 zeros and only one 1.
- Then replace this new set of parts by the concatenation of its parts.
- Then replace this string by its mirror version which is a binary number.
T(n,k) is the decimal value of this binary number, which represents the k-th partition of n (see example).
The partitions of n are represented by a subsequence with A000041(n) integers starting with 2^(n-1) and ending with 2^n - 1, n >= 1. The odd numbers of the sequence are in A000225.
First differs from A065609 at a(23).
Conjecture: this sequence is a sorted version of b(n) where b(2^k) = 2^k for k >= 0, b(n) = A080100(n)*(2*b(A053645(n)) + 1) otherwise. - Mikhail Kurkov, Oct 21 2023

Examples

			T(6,8) = 58 because 58 in base 2 is 111010 whose mirror is 010111 which is the concatenation of 01, 01, 1, 1, whose number of digits are 2, 2, 1, 1, which are also the 8th partition of 6.
Illustration of initial terms:
The sequence represents a table of partitions (see below):
--------------------------------------------------------
.            Binary                        Partitions
n  k  T(n,k) number  Mirror   Diagram       (A026792)
.                                          1 2 3 4 5 6
--------------------------------------------------------
.                             _
1  1     1       1    1        |           1,
.                             _ _
1  1     2      10    01      _  |           2,
2  2     3      11    11       | |         1,1,
.                             _ _ _
3  1     4     100    001     _ _  |           3,
3  2     6     110    011     _  | |         2,1,
3  3     7     111    111      | | |       1,1,1,
.                             _ _ _ _
4  1     8    1000    0001    _ _    |           4,
4  2    10    1010    0101    _ _|_  |         2,2,
4  3    12    1100    0011    _ _  | |         3,1,
4  4    14    1110    0111    _  | | |       2,1,1,
4  5    15    1111    1111     | | | |     1,1,1,1,
.                             _ _ _ _ _
5  1    16   10000    00001   _ _ _    |           5,
5  2    20   10100    00101   _ _ _|_  |         3,2,
5  3    24   11000    00011   _ _    | |         4,1,
5  4    26   11010    01011   _ _|_  | |       2,2,1,
5  5    28   11100    00111   _ _  | | |       3,1,1,
5  6    30   11110    01111   _  | | | |     2,1,1,1,
5  7    31   11111    11111    | | | | |   1,1,1,1,1,
.                             _ _ _ _ _ _
6  1    32  100000    000001  _ _ _      |           6
6  2    36  100100    001001  _ _ _|_    |         3,3,
6  3    40  101000    000101  _ _    |   |         4,2,
6  4    42  101010    010101  _ _|_ _|_  |       2,2,2,
6  5    48  110000    000011  _ _ _    | |         5,1,
6  6    52  110100    001011  _ _ _|_  | |       3,2,1,
6  7    56  111000    000111  _ _    | | |       4,1,1,
6  8    58  111010    010111  _ _|_  | | |     2,2,1,1,
6  9    60  111100    001111  _ _  | | | |     3,1,1,1,
6  10   62  111110    011111  _  | | | | |   2,1,1,1,1,
6  11   63  111111    111111   | | | | | | 1,1,1,1,1,1,
.
Triangle begins:
  1;
  2,   3;
  4,   6,  7;
  8,  10, 12, 14, 15;
  16, 20, 24, 26, 28, 30, 31;
  32, 36, 40, 42, 48, 52, 56, 58, 60, 62, 63;
  ...
From _Gus Wiseman_, Apr 01 2020: (Start)
Using the encoding of A066099, this sequence ranks all finite nonempty multisets, as follows.
   1: {1}
   2: {2}
   3: {1,1}
   4: {3}
   6: {1,2}
   7: {1,1,1}
   8: {4}
  10: {2,2}
  12: {1,3}
  14: {1,1,2}
  15: {1,1,1,1}
  16: {5}
  20: {2,3}
  24: {1,4}
  26: {1,2,2}
  28: {1,1,3}
  30: {1,1,1,2}
  31: {1,1,1,1,1}
(End)
		

Crossrefs

Column 1 is A000079. Row n has length A000041(n). Right border gives A000225.
The case covering an initial interval is A333379 or A333380.
All of the following pertain to compositions in the order of A066099.
- The weakly increasing version is this sequence.
- The weakly decreasing version is A114994.
- The strictly increasing version is A333255.
- The strictly decreasing version is A333256.
- The unequal version is A233564.
- The equal version is A272919.
- The case covering an initial interval is A333217.
- Initial intervals are ranked by A164894.
- Reversed initial intervals are ranked by A246534.

Programs

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Select[Range[0,100],LessEqual@@stc[#]&] (* Gus Wiseman, Apr 01 2020 *)

Formula

Conjecture: a(A000070(m) - k) = 2^m - A228354(k) for m > 0, 0 < k <= A000041(m). - Mikhail Kurkov, Oct 20 2023
Showing 1-10 of 148 results. Next