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

A003242 Number of compositions of n such that no two adjacent parts are equal (these are sometimes called Carlitz compositions).

Original entry on oeis.org

1, 1, 1, 3, 4, 7, 14, 23, 39, 71, 124, 214, 378, 661, 1152, 2024, 3542, 6189, 10843, 18978, 33202, 58130, 101742, 178045, 311648, 545470, 954658, 1670919, 2924536, 5118559, 8958772, 15680073, 27443763, 48033284, 84069952, 147142465, 257534928, 450748483, 788918212
Offset: 0

Views

Author

E. Rodney Canfield

Keywords

Examples

			From _Joerg Arndt_, Oct 27 2012:  (Start)
The 23 such compositions of n=7 are
[ 1]  1 2 1 2 1
[ 2]  1 2 1 3
[ 3]  1 2 3 1
[ 4]  1 2 4
[ 5]  1 3 1 2
[ 6]  1 3 2 1
[ 7]  1 4 2
[ 8]  1 5 1
[ 9]  1 6
[10]  2 1 3 1
[11]  2 1 4
[12]  2 3 2
[13]  2 4 1
[14]  2 5
[15]  3 1 2 1
[16]  3 1 3
[17]  3 4
[18]  4 1 2
[19]  4 2 1
[20]  4 3
[21]  5 2
[22]  6 1
[23]  7
(End)
		

References

  • Miklos Bona, editor, Handbook of Enumerative Combinatorics, CRC Press, 2015, page 191.

Crossrefs

Row sums of A232396, A241701.
Cf. A241902.
Column k=1 of A261960.
Cf. A048272.
Compositions with adjacent parts coprime are A167606.
The complement is counted by A261983.

Programs

Formula

a(n) = Sum_{k=1..n} A048272(k)*a(n-k), n>1, a(0)=1. - Vladeta Jovovic, Feb 05 2002
G.f.: 1/(1 - Sum_{k>0} x^k/(1+x^k)).
a(n) ~ c r^n where c is approximately 0.456387 and r is approximately 1.750243. (Formula from Knopfmacher and Prodinger reference.) - Franklin T. Adams-Watters, May 27 2010. With better precision: r = 1.7502412917183090312497386246398158787782058181381590561316586... (see A241902), c = 0.4563634740588133495321001859298593318027266156100046548066205... - Vaclav Kotesovec, Apr 30 2014
G.f. is the special case p=2 of 1/(1 - Sum_{k>0} (z^k/(1-z^k) - p*z^(k*p)/(1-z^(k*p)))), see A129922. - Joerg Arndt, Apr 28 2013
G.f.: 1/(1 - x * (d/dx) log(Product_{k>=1} (1 + x^k)^(1/k))). - Ilya Gutkovskiy, Oct 18 2018
Moebius transform of A329738. - Gus Wiseman, Nov 27 2019
For n>=2, a(n) = A128695(n) - A091616(n). - Vaclav Kotesovec, Jul 07 2020

Extensions

More terms from David W. Wilson

A005251 a(0) = 0, a(1) = a(2) = a(3) = 1; thereafter, a(n) = a(n-1) + a(n-2) + a(n-4).

Original entry on oeis.org

0, 1, 1, 1, 2, 4, 7, 12, 21, 37, 65, 114, 200, 351, 616, 1081, 1897, 3329, 5842, 10252, 17991, 31572, 55405, 97229, 170625, 299426, 525456, 922111, 1618192, 2839729, 4983377, 8745217, 15346786, 26931732, 47261895, 82938844, 145547525, 255418101, 448227521
Offset: 0

Views

Author

Keywords

Comments

a(n+3) is the number of n-bit sequences that avoid 010. Example: For n=4 the 12 sequences are all 4-bit sequences except 0100, 0101, 0010, 1010. - David Callan, Mar 25 2004
a(n+2) is the number of compositions (ordered partitions) of n where no two adjacent parts are != 1, see example. - Joerg Arndt, Jan 26 2013
a(n+1) is the number of compositions of n avoiding the part 2. - Joerg Arndt, Jul 13 2014
Number of different positive braids with n crossings of 3 strands.
This is a_2(n) in the Doroslovacki reference. Note that there is a typo in the paper in the formula for a_2(n): the upper bound in the inner sum should be "n-i" not "i-1". - Max Alekseyev, Jun 26 2007
a(n) is the number of peakless Motzkin paths of length n-1 with no UHH...HD's starting at level > 0 (here n > 0 and U=(1,1), H=(1,0), D=(1,-1)). Example: a(5)=7 because from all 8 peakless Motzkin paths of length 5 (see A004148) only UUHDD does not qualify. - Emeric Deutsch, Sep 13 2004
Equals the INVERT transform of (1, 0, 1, 1, 1, ...); equivalent to a(n) = a(n-1) + a(n-3) + a(n-4) + ... - Gary W. Adamson, Apr 27 2009
a(n) is the number of length n-1 words on {0,1} such that each string of 1's is followed by a string of at least two 0's. For example, a(5) = 4 because we have: 0000, 0100, 1000, and 1100. - Geoffrey Critzer, Aug 09 2013
a(n+1) is the top left entry of the n-th power of any of the 3 X 3 matrices [1, 1, 0; 0, 1, 1; 1, 0, 0] or [1, 0, 1; 1, 1, 0; 0, 1, 0] or [1, 1, 0; 0, 0, 1; 1, 0, 1] or [1, 0, 1; 1, 0, 0; 0, 1, 1]. - R. J. Mathar, Feb 03 2014
For n >= 2, a(n) is the number of (n-2)-length binary words with no isolated zeros. - Milan Janjic, Mar 07 2015
Apart from the first three terms, the total number of bargraphs of semiperimeter n of height at most two for n >= 2 starts 1, 2, 4, 7, 12, ... - Arnold Knopfmacher, Nov 02 2016
Number of DD-equivalence classes of Łukasiewicz paths. Łukasiewicz paths are DD-equivalent iff the positions of pattern DD are identical in these paths. - Sergey Kirgizov, Apr 08 2018
From Gus Wiseman, Nov 25 2019: (Start)
For n > 0, also the number of subsets of {1, ..., n - 3} such that if x and x + 2 are both in the subset, then so is x + 1. For example, the a(3) = 1 through a(7) = 12 subsets are:
{} {} {} {} {}
{1} {1} {1} {1}
{2} {2} {2}
{1,2} {3} {3}
{1,2} {4}
{2,3} {1,2}
{1,2,3} {1,4}
{2,3}
{3,4}
{1,2,3}
{2,3,4}
{1,2,3,4}
(End)
The two-dimensional version, which counts sets of pairs where, if two pairs are separated by graph-distance 2, then the intermediate pair or pairs are also in the set, is A329871. - Gus Wiseman, Nov 30 2019
a(n+1) is the number of ways to tile a strip of length n with squares, dominoes, and tetrominoes, where the first tile cannot be a domino. - Greg Dresden and Myanna Nash, Aug 18 2020
For n>=3, a(n) is the number of binary strings of length n-2 without any maximal runs of ones of length 1. - Félix Balado, Aug 25 2025

Examples

			From _Joerg Arndt_, Jan 26 2013: (Start)
The a(5+2) = 12 compositions of 5 where no two adjacent parts are != 1 are
  [ 1]  [ 1 1 1 1 1 ]
  [ 2]  [ 1 1 1 2 ]
  [ 3]  [ 1 1 2 1 ]
  [ 4]  [ 1 1 3 ]
  [ 5]  [ 1 2 1 1 ]
  [ 6]  [ 1 3 1 ]
  [ 7]  [ 1 4 ]
  [ 8]  [ 2 1 1 1 ]
  [ 9]  [ 2 1 2 ]
  [10]  [ 3 1 1 ]
  [11]  [ 4 1 ]
  [12]  [ 5 ]
(End)
G.f. = x + x^2 + x^3 + 2*x^4 + 4*x^5 + 7*x^6 + 12*x^7 + 21*x^8 + 37*x^9 + ...
		

References

  • S. Burckel, Efficient methods for three strand braids (submitted). [Apparently unpublished]
  • P. Chinn and S. Heubach, "Compositions of n with no occurrence of k", Congressus Numeratium, 2002, v. 162, pp. 33-51.
  • John H. Conway and R. K. Guy, The Book of Numbers, Copernicus Press, p. 205.
  • R. K. Guy, "Anyone for Twopins?" in D. A. Klarner, editor, The Mathematical Gardner. Prindle, Weber and Schmidt, Boston, 1981, pp. 2-15.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Bisection of Padovan sequence A000931.
Partial sums of A005314 shifted 3 times to the right, if we assume A005314(0) = 1.
Compositions without adjacent equal parts are A003242.
Compositions without isolated parts are A114901.
Row sums of A097230(n-2) for n>1.

Programs

  • Haskell
    a005251 n = a005251_list !! n
    a005251_list = 0 : 1 : 1 : 1 : zipWith (+) a005251_list
       (drop 2 $ zipWith (+) a005251_list (tail a005251_list))
    -- Reinhard Zumkeller, Dec 28 2011
    
  • Magma
    I:=[0,1,1,1]; [n le 4 select I[n] else Self(n-1)+Self(n-2)+Self(n-4): n in [1..45]]; // Vincenzo Librandi, Nov 30 2018
    
  • Magma
    R:=PowerSeriesRing(Integers(), 40); [0] cat Coefficients(R!( x*(1-x)/(1-2*x + x^2 - x^3) )); // Marius A. Burtea, Oct 24 2019
    
  • Maple
    A005251 := proc(n) option remember; if n <= 2 then n elif n = 3 then 4 else 2*A005251(n - 1) - A005251(n - 2) + A005251(n - 3); fi; end;
    A005251:=(-1+z)/(-1+2*z-z**2+z**3); # Simon Plouffe in his 1992 dissertation
    a := n -> `if`(n<=1, n, hypergeom([(2-n)/3, 1-n/3, (1-n)/3], [1/2, -n+1], 27/4)):
    seq(simplify(a(n)), n=0..36); # Peter Luschny, Apr 08 2018
  • Mathematica
    LinearRecurrence[{2,-1,1},{0,1,1},40]  (* Harvey P. Dale, May 05 2011 *)
    a[ n_]:= If[n<0, SeriesCoefficient[ -x(1-x)/(1 -x + 2x^2 -x^3), {x, 0, -n}], SeriesCoefficient[ x(1-x)/(1 -2x +x^2 -x^3), {x, 0, n}]] (* Michael Somos, Dec 13 2013 *)
    a[0] = 1; a[1] = a[2] = 0; a[n_] := a[n] = a[n-2] + a[n-3]; Table[a[2 n-1], {n, 1, 20}] (* Rigoberto Florez, Oct 15 2019 *)
    Table[If[n==0,0,Length[DeleteCases[Subsets[Range[n-3]],{_,x_,y_,_}/;x+2==y]]],{n,0,10}] (* Gus Wiseman, Nov 25 2019 *)
  • PARI
    Vec((1-x)/(1-2*x+x^2-x^3)+O(x^99)) /* Charles R Greathouse IV, Nov 20 2012 */
    
  • PARI
    {a(n) = if( n<0, polcoeff( -x*(1-x)/(1 -x +2*x^2 -x^3) + x*O(x^-n), -n), polcoeff( x*(1-x)/(1 -2*x +x^2 -x^3) + x*O(x^n), n))} /* Michael Somos, Dec 13 2013 */
    
  • SageMath
    [sum( binomial(n-j-1, 2*j) for j in (0..floor((n-1)/3)) ) for n in (0..50)] # G. C. Greubel, Apr 13 2022

Formula

a(n) = 2*a(n-1) - a(n-2) + a(n-3).
G.f.: z*(1-z)/(1 - 2*z + z^2 - z^3). - Emeric Deutsch, Sep 13 2004
23*a_n = 3*P_{2n+1} + 7*P_{2n} - 2*P_{2n-1}, where P_n are the Perrin numbers, A001608. - Don Knuth, Dec 09 2008
a(n+1) = Sum_{k=0..n} binomial(n-k, 2k). - Richard L. Ollerton, May 12 2004
From Henry Bottomley, Feb 21 2001: (Start)
a(n) = (Sum_{j
a(n) = A005314(n) - A005314(n-1).
a(n) = A049853(n-1) - a(n-1).
a(n) = A005314(n) - a(n-2). (End)
Conjecture: a(n+1) + |A078065(n)| = 2*A005314(n+1). - Creighton Dement, Dec 21 2004
a(n+2) has g.f. (F_3(-x) + F_2(-x))/(F_4(-x) + F_3(-x)) = 1/(-x+1/(-x+1/(-x+1))) where F_n(x) is the n-th Fibonacci polynomial; see A011973. - Qiaochu Yuan (qchu(AT)mit.edu), Feb 19 2009
a(n) = A173022(2^(n-2) - 1) for n > 1. - Reinhard Zumkeller, Feb 07 2010
BINOMIAL transform of A176971 is a(n+1). - Michael Somos, Dec 13 2013
a(n) = hypergeom([(2-n)/3, 1-n/3, (1-n)/3], [1/2, -n+1], 27/4) for n > 1. - Peter Luschny, Apr 08 2018
G.f.: z/(1-z-z^3-z^4-z^5-...) for the compositions of n-1 avoiding 2. The g.f. for the number of compositions of n avoiding the part k is 1/(1-z-...-z^(k-1) - z^(k+1)-...). - Gregory L. Simay, Sep 09 2018
If p,q,r are the three solutions to x^3 = 2x^2 - x + 1, then a(n) = (p-1)*p^n/((p-q)*(p-r)) + (q-1)*q^n/((q-p)*(q-r)) + (r-1)*r^n/((r-p)*(r-q)). - Greg Dresden and AnXing Yang, Aug 12 2025

A006498 a(n) = a(n-1) + a(n-3) + a(n-4), a(0) = a(1) = a(2) = 1, a(3) = 2.

Original entry on oeis.org

1, 1, 1, 2, 4, 6, 9, 15, 25, 40, 64, 104, 169, 273, 441, 714, 1156, 1870, 3025, 4895, 7921, 12816, 20736, 33552, 54289, 87841, 142129, 229970, 372100, 602070, 974169, 1576239, 2550409, 4126648, 6677056, 10803704, 17480761, 28284465, 45765225, 74049690, 119814916
Offset: 0

Keywords

Comments

Number of compositions of n into 1's, 3's and 4's. - Len Smiley, May 08 2001
The sum of any two alternating terms (terms separated by one term) produces a number from the Fibonacci sequence. (e.g. 4+9=13, 9+25=34, 6+15=21, etc.) Taking square roots starting from the first term and every other term after, we get the Fibonacci sequence. - Sreyas Srinivasan (sreyas_srinivasan(AT)hotmail.com), May 02 2002
(1 + x + 2*x^2 + x^3)/(1 - x - x^3 - x^4) = 1 + 2*x + 4*x^2 + 6*x^3 + 9*x^4 + 15*x^5 + 25*x^6 + 40*x^7 + ... is the g.f. for the number of binary strings of length where neither 101 nor 111 occur. [Lozansky and Rousseau] Or, equivalently, where neither 000 nor 010 occur.
Equivalently, a(n+2) is the number of length-n binary strings with no two set bits with distance 2; see fxtbook link. - Joerg Arndt, Jul 10 2011
a(n) is the number of words written with the letters "a" and "b", with the following restriction: any "a" must be followed by at least two letters, the second of which is a "b". - Bruno Petazzoni (bpetazzoni(AT)ac-creteil.fr), Oct 31 2005. [This is also equivalent to the previous two conditions.]
Let a(0) = 1, then a(n) = partial products of Product_{n>2} (F(n)/F(n-1))^2 = 1*1*2*2*(3/2)*(3/2)*(5/3)*(5/3)*(8/5)*(8/5)*.... E.g., a(7) = 15 = 1*1*1*2*2*(3/2)*(3/2)*(5/3). - Gary W. Adamson, Dec 13 2009
Number of permutations satisfying -k <= p(i) - i <= r and p(i)-i not in I, i=1..n, with k=1, r=3, I={1}. - Vladimir Baltic, Mar 07 2012
The 2-dimensional version, which counts sets of pairs no two of which are separated by graph-distance 2, is A273461. - Gus Wiseman, Nov 27 2019
a(n+1) is the number of multus bitstrings of length n with no runs of 4 ones. - Steven Finch, Mar 25 2020

Examples

			G.f. = 1 + x + x^2 + 2*x^3 + 4*x^4 + 6*x^5 + 9*x^6 + 15*x^7 + 25*x^8 + 40*x^9 + ...
From _Gus Wiseman_, Nov 27 2019: (Start)
The a(2) = 1 through a(7) = 15 subsets with no two elements differing by 2:
  {}  {}   {}     {}     {}     {}
      {1}  {1}    {1}    {1}    {1}
           {2}    {2}    {2}    {2}
           {1,2}  {3}    {3}    {3}
                  {1,2}  {4}    {4}
                  {2,3}  {1,2}  {5}
                         {1,4}  {1,2}
                         {2,3}  {1,4}
                         {3,4}  {1,5}
                                {2,3}
                                {2,5}
                                {3,4}
                                {4,5}
                                {1,2,5}
                                {1,4,5}
(End)
		

References

  • E. Lozansky and C. Rousseau, Winning Solutions, Springer, 1996; see pp. 157 and 172.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A060945 (for 1's, 2's and 4's). Essentially the same as A074677.
Diagonal sums of number triangle A059259.
Numbers whose binary expansion has no subsequence (1,0,1) are A048716.

Programs

  • Haskell
    a006498 n = a006498_list !! n
    a006498_list = 1 : 1 : 1 : 2 : zipWith (+) (drop 3 a006498_list)
       (zipWith (+) (tail a006498_list) a006498_list)
    -- Reinhard Zumkeller, Apr 07 2012
  • Magma
    [ n eq 1 select 1 else n eq 2 select 1 else n eq 3 select 1 else n eq 4 select 2 else Self(n-1)+Self(n-3)+ Self(n-4): n in [1..40] ]; // Vincenzo Librandi, Aug 20 2011
    
  • Mathematica
    LinearRecurrence[{1,0,1,1},{1,1,1,2},50] (* Harvey P. Dale, Jul 13 2011 *)
    Table[Fibonacci[Floor[n/2] + 2]^Mod[n, 2]*Fibonacci[Floor[n/2] + 1]^(2 - Mod[n, 2]), {n, 0, 40}] (* David Nacin, Feb 29 2012 *)
    a[ n_] := Fibonacci[ Quotient[ n+2, 2]] Fibonacci[ Quotient[ n+3, 2]] (* Michael Somos, Jan 19 2014 *)
    Table[Length[Select[Subsets[Range[n]],!MatchQ[#,{_,x_,_,y_,_}/;x+2==y]&]],{n,10}] (* Gus Wiseman, Nov 27 2019 *)
  • PARI
    {a(n) = fibonacci( (n+2)\2 ) * fibonacci( (n+3)\2 )} /* Michael Somos, Mar 10 2004 */
    
  • PARI
    Vec(1/(1-x-x^3-x^4)+O(x^66))
    
  • Python
    def a(n, adict={0:1, 1:1, 2:1, 3:2}):
        if n in adict:
            return adict[n]
        adict[n]=a(n-1)+a(n-3)+a(n-4)
        return adict[n] # David Nacin, Mar 07 2012
    

Formula

G.f.: 1 / ((1 + x^2) * (1 - x - x^2)); a(2*n) = F(n+1)^2, a(2*n - 1) = F(n+1)*F(n). a(n) = a(-4-n) * (-1)^n. - Michael Somos, Mar 10 2004
The g.f. -(1+z+2*z^2+z^3)/((z^2+z-1)*(1+z^2)) for the truncated version 1, 2, 4, 6, 9, 15, 25, 40, ... was given in the Simon Plouffe thesis of 1992. [edited by R. J. Mathar, May 13 2008]
From Vladeta Jovovic, May 03 2002: (Start)
a(n) = round((-(1/5)*sqrt(5) - 1/5)*(-2*1/(-sqrt(5)+1))^n/(-sqrt(5)+1) + ((1/5)*sqrt(5) - 1/5)*(-2*1/( sqrt(5)+1))^n/(sqrt(5)+1)).
G.f.: 1/(1-x-x^2)/(1+x^2). (End)
a(n) = (-i)^n*Sum{k=0..n} U(n-2k, i/2) where i^2=-1. - Paul Barry, Nov 15 2003
a(n) = Sum_{k=0..floor(n/2)} (-1)^k*F(n-2k+1). - Paul Barry, Oct 12 2007
F(floor(n/2) + 2)^(n mod 2)*F(floor(n/2) + 1)^(2 - (n mod 2)) where F(n) is the n-th Fibonacci number. - David Nacin, Feb 29 2012
a(2*n - 1) = A001654(n), a(2*n) = A007598(n+1). - Michael Somos, Mar 10 2004
a(n+1)*a(n+3) = a(n)*a(n+2) + a(n+1)*a(n+2) for all n in Z. - Michael Somos, Jan 19 2014
a(n) = round(1/(1/F(n+2) + 2/F(n+3))), where F(n) = A000045, and 0.5 is rounded to 1. - Richard R. Forberg, Aug 04 2014
5*a(n) = (-1)^floor(n/2)*A000034(n+1) + A000032(n+2). - R. J. Mathar, Sep 16 2017
a(n) = Sum_{j=0..floor(n/3)} Sum_{k=0..j} binomial(n-3j,k)*binomial(j,k)*2^k. - Tony Foster III, Sep 18 2017
E.g.f.: (2*cos(x) + sin(x) + exp(x/2)*(3*cosh(sqrt(5)*x/2) + sqrt(5)*sinh(sqrt(5)*x/2)))/5. - Stefano Spezia, Mar 12 2024

A005314 For n = 0, 1, 2, a(n) = n; thereafter, a(n) = 2*a(n-1) - a(n-2) + a(n-3).

Original entry on oeis.org

0, 1, 2, 3, 5, 9, 16, 28, 49, 86, 151, 265, 465, 816, 1432, 2513, 4410, 7739, 13581, 23833, 41824, 73396, 128801, 226030, 396655, 696081, 1221537, 2143648, 3761840, 6601569, 11584946, 20330163, 35676949, 62608681, 109870576, 192809420, 338356945, 593775046
Offset: 0

Keywords

Comments

Number of compositions of n into parts congruent to {1,2} mod 4. - Vladeta Jovovic, Mar 10 2005
a(n)/a(n-1) tends to A109134; an eigenvalue of the matrix M and a root to the characteristic polynomial. - Gary W. Adamson, May 25 2007
Starting with offset 1 = INVERT transform of (1, 1, 0, 0, 1, 1, 0, 0, ...). - Gary W. Adamson, May 04 2009
a(n-2) is the top left entry of the n-th power of the 3 X 3 matrix [0, 1, 0; 0, 1, 1; 1, 0, 1] or of the 3 X 3 matrix [0, 0, 1; 1, 1, 0; 0, 1, 1]. - R. J. Mathar, Feb 03 2014
Counts closed walks of length (n+2) at a vertex of a unidirectional triangle containing a loop on remaining two vertices. - David Neil McGrath, Sep 15 2014
Also the number of binary words of length n that begin with 1 and avoid the subword 101. a(5) = 9: 10000, 10001, 10010, 10011, 11000, 11001, 11100, 11110, 11111. - Alois P. Heinz, Jul 21 2016
Also the number of binary words of length n-1 such that every two consecutive 0s are immediately followed by at least two consecutive 1s. a(4) = 5: 010, 011, 101, 110, 111. - Jerrold Grossman, May 03 2024

Examples

			G.f. = x + 2*x^2 + 3*x^3 + 5*x^4 + 9*x^5 + 16*x^6 + 28*x^7 + 49*x^8 + ...
From _Gus Wiseman_, Nov 25 2019: (Start)
a(n) is the number of subsets of {1..n} containing n such that if x and x + 2 are both in the subset, then so is x + 1. For example, the a(1) = 1 through a(5) = 9 subsets are:
  {1}  {2}    {3}      {4}        {5}
       {1,2}  {2,3}    {1,4}      {1,5}
              {1,2,3}  {3,4}      {2,5}
                       {2,3,4}    {4,5}
                       {1,2,3,4}  {1,2,5}
                                  {1,4,5}
                                  {3,4,5}
                                  {2,3,4,5}
                                  {1,2,3,4,5}
(End)
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Equals row sums of triangle A099557.
Equals row sums of triangle A224838.
Cf. A011973 (starting with offset 1 = Falling diagonal sums of triangle with rows displayed as centered text).
First differences of A005251, shifted twice to the left.

Programs

  • Haskell
    a005314 n = a005314_list !! n
    a005314_list = 0 : 1 : 2 : zipWith (+) a005314_list
       (tail $ zipWith (-) (map (2 *) $ tail a005314_list) a005314_list)
    -- Reinhard Zumkeller, Oct 14 2011
    
  • Magma
    [0] cat [n le 3 select n else 2*Self(n-1) - Self(n-2) + Self(n-3):n in [1..35]]; // Marius A. Burtea, Oct 24 2019
    
  • Magma
    R:=PowerSeriesRing(Integers(), 36); [0] cat Coefficients(R!( x/(1-2*x+x^2-x^3))); // Marius A. Burtea, Oct 24 2019
    
  • Maple
    A005314 := proc(n)
        option remember ;
        if n <=2 then
            n;
        else
            2*procname(n-1)-procname(n-2)+procname(n-3) ;
        end if;
    end proc:
    seq(A005314(n),n=0..20) ; # R. J. Mathar, Feb 25 2024
  • Mathematica
    LinearRecurrence[{2, -1, 1}, {0, 1, 2}, 100] (* Vladimir Joseph Stephan Orlovsky, Jul 03 2011 *)
    Table[Sum[Binomial[n - Floor[(k + 1)/2], n - Floor[(3 k - 1)/2]], {k, 0, n}], {n, 0, 100}] (* John Molokach, Jul 21 2013 *)
    Table[Sum[Binomial[n - Floor[(4 n + 15 - 6 k + (-1)^k)/12], n - Floor[(4 n + 15 - 6 k + (-1)^k)/12] - Floor[(2 n - 1)/3] + k - 1], {k, 1, Floor[(2 n + 2)/3]}], {n, 0, 100}] (* John Molokach, Jul 25 2013 *)
    a[ n_] := If[ n < 0, SeriesCoefficient[ x^2 / (1 - x + 2 x^2 - x^3), {x, 0, -n}], SeriesCoefficient[ x / (1 - 2 x + x^2 - x^3), {x, 0, n}]]; (* Michael Somos, Dec 13 2013 *)
    RecurrenceTable[{a[0]==0,a[1]==1,a[2]==2,a[n]==2a[n-1]-a[n-2]+a[n-3]},a,{n,40}] (* Harvey P. Dale, May 13 2018 *)
    Table[Length[Select[Subsets[Range[n]],MemberQ[#,n]&&!MatchQ[#,{_,x_,y_,_}/;x+2==y]&]],{n,0,10}] (* Gus Wiseman, Nov 25 2019 *)
  • PARI
    {a(n) = sum(k=0, (2*n-1)\3, binomial(n-1-k\2, k))}
    
  • PARI
    {a(n) = if( n<0, polcoeff( x^2 / (1 - x + 2*x^2 - x^3) + x * O(x^-n), -n), polcoeff( x / (1 - 2*x + x^2 - x^3) + x * O(x^n), n))}; /* Michael Somos, Sep 18 2012 */
    
  • SageMath
    def A005314(n): return sum( binomial(n-k, 2*k+1) for k in range(floor((n+2)/3)) )
    [A005314(n) for n in range(51)] # G. C. Greubel, Nov 10 2023

Formula

From Paul D. Hanna, Oct 22 2004: (Start)
G.f.: x/(1-2*x+x^2-x^3).
a(n) = Sum_{k=0..[(2n-1)/3]} binomial(n-1-[k/2], k), where [x]=floor(x). (End)
a(n) = Sum_{k=0..n} binomial(n-k, 2*k+1).
23*a_n = 3*P_{2n+2} + 7*P_{2n+1} - 2*P_{2n}, where P_n are the Perrin numbers, A001608. - Don Knuth, Dec 09 2008
G.f. (1-z)*(1+z^2)/(1-2*z+z^2-z^3) for the augmented version 1, 1, 2, 3, 5, 9, 16, 28, 49, 86, 151, ... was given in Simon Plouffe's thesis of 1992.
a(n) = a(n-1) + a(n-2) + a(n-4) = a(n-2) + A049853(n-1) = a(n-1) + A005251(n) = Sum_{i <= n} A005251(i).
a(n) = Sum_{k=0..floor((n-1)/3)} binomial(n-k, 2*k+1). - Richard L. Ollerton, May 12 2004
M^n*[1,0,0] = [a(n-2), a(n-1), a]; where M = the 3 X 3 matrix [0,1,0; 0,0,1; 1,-1,2]. Example M^5*[1,0,0] = [3,5,9]. - Gary W. Adamson, May 25 2007
a(n) = A000931(2*n + 4). - Michael Somos, Sep 18 2012
a(n) = A077954(-n - 2). - Michael Somos, Sep 18 2012
G.f.: 1/( 1 - Sum_{k>=0} x*(x-x^2+x^3)^k ) - 1. - Joerg Arndt, Sep 30 2012
a(n) = Sum_{k=0..n} binomial( n-floor((k+1)/2), n-floor((3k-1)/2) ). - John Molokach, Jul 21 2013
a(n) = Sum_{k=1..floor((2*n+2)/3)} binomial(n - floor((4*n+15-6*k+(-1)^k)/12), n - floor((4*n+15-6*k+(-1)^k)/12) - floor((2*n-1)/3) + k - 1). - John Molokach, Jul 24 2013
a(n) = round(A001608(2n+1)*r) where r is the real root of 23*x^3 - 23*x^2 + 8*x - 1 = 0, r = 0.4114955... - Richard Turk, Oct 24 2019
a(n+2) = n + 2 + Sum_{k=0..n} (n-k)*a(k). - Greg Dresden and Yichen P. Wang, Sep 16 2021
a(n) ~ (19 - r + 11*r^2) / (23 * r^(n-1)), where r = 0.569840290998... is the root of the equation r*(2 - r + r^2) = 1. - Vaclav Kotesovec, Apr 14 2024
a(n) = n*3F2(1/3-n/3,2/3-n/3,1-n/3;-n,3/2;27/4). - R. J. Mathar, Jun 27 2024
If p,q,r are the three solutions to x^3 = 2x^2 - x + 1, then a(n) = p^(n+1)/((p-q)*(p-r)) + q^(n+1)/((q-p)*(q-r)) + r^(n+1)/((r-p)*(r-q)). Compare to similar formula for A005251. - Greg Dresden and AnXing Yang, Aug 19 2025

Extensions

More terms and additional formulas from Henry Bottomley, Jul 21 2000
Plouffe's g.f. edited by R. J. Mathar, May 12 2008

A247100 The number of ways to write an n-bit binary string and then define each run of ones as an element in an equivalence relation.

Original entry on oeis.org

1, 2, 4, 9, 21, 51, 127, 324, 844, 2243, 6073, 16737, 46905, 133556, 386062, 1132107, 3365627, 10137559, 30920943, 95457178, 298128278, 941574417, 3006040523, 9697677885, 31602993021, 104001763258, 345524136076, 1158570129917, 3919771027105, 13377907523151
Offset: 0

Author

Andrew Woods, Jan 01 2015

Keywords

Comments

Also the number of partitions of subsets of {1,...,n}, where consecutive integers are required to be in the same part. Example: For n=3 the a(3)=9 partitions are {}, 1, 2, 3, 12, 23, 13, 1|3, 123. - Don Knuth, Aug 07 2015

Examples

			The labeled-run binary strings can be written as follows.
For n=1: 0, 1.
For n=2: 00, 01, 10, 11.
For n=3: 000, 001, 010, 100, 011, 110, 111, 101, 102.
For n=4: 0000, 0001, 0010, 0100, 1000, 0011, 0110, 1100, 0111, 1110, 1111, 0101, 0102, 1001, 1002, 1010, 1020, 1011, 1022, 1101, 1102.
For n=5, the original binary string 10101 can be written as 10101, 10102, 10201, 10202, or 10203 because there are 3 runs of ones and Bell(3)=5.
		

Programs

  • Maple
    with(combinat):
    a:= n-> (t-> add(binomial(t, 2*j)*bell(j), j=0..t/2))(n+1):
    seq(a(n), n=0..30);  # Alois P. Heinz, Aug 10 2015
  • Mathematica
    Table[1 + Sum[Binomial[n+1,2*k] * BellB[k],{k,1,Ceiling[n/2]}],{n,1,40}] (* Vaclav Kotesovec, Jan 08 2015 after Andrew Woods *)

Formula

a(n) = 1 + Sum_{k=1..ceiling(n/2)} binomial(n+1, 2k)*Bell(k), where Bell(x) refers to Bell numbers (A000110).

Extensions

a(0)=1 prepended by Alois P. Heinz, Aug 08 2015

A261134 Number of partitions of subsets s of {1,...,n}, where all integers belonging to a run of consecutive members of s are required to be in different parts.

Original entry on oeis.org

1, 2, 4, 9, 23, 66, 209, 722, 2697, 10825, 46429, 211799, 1023304, 5217048, 27974458, 157310519, 925326848, 5680341820, 36315837763, 241348819913, 1664484383610, 11893800649953, 87931422125632, 671699288516773, 5295185052962371, 43029828113547685
Offset: 0

Author

Alois P. Heinz, Aug 10 2015

Keywords

Examples

			a(3) = 9: {}, 1, 2, 3, 1|2, 2|3, 13, 1|3, 1|2|3.
a(4) = 23: {}, 1, 2, 3, 4, 1|2, 1|3, 13, 1|4, 14, 2|3, 2|4, 24, 3|4, 1|2|3, 1|2|4, 1|24, 14|2, 1|3|4, 13|4, 14|3, 2|3|4, 1|2|3|4.
		

Crossrefs

Programs

  • Maple
    g:= proc(n, s, t) option remember; `if`(n=0, 1, add(
          `if`(j in s, 0, g(n-1, `if`(j=0, {}, s union {j}),
          `if`(j=t, t+1, t))), j=0..t))
        end:
    a:= n-> g(n, {}, 1):
    seq(a(n), n=0..20);
  • Mathematica
    g[n_, s_List, t_] := g[n, s, t] = If[n == 0, 1, Sum[If[MemberQ[s, j], 0, g[n-1, If[j == 0, {}, s ~Union~ {j}], If[j == t, t+1, t]]], {j, 0, t}]]; a[n_] := g[n, {}, 1]; Table[a[n], {n, 0, 20}] (* Jean-François Alcover, Feb 04 2017, translated from Maple *)

A261489 Number of partitions of subsets of {1,...,n}, where consecutive integers and the elements in {1, n} are required to be in different parts.

Original entry on oeis.org

1, 2, 4, 8, 25, 82, 313, 1318, 6098, 30603, 165282, 954065, 5853242, 37987146, 259751877, 1864926846, 14016442573, 109985575616, 898948324164, 7637000950875, 67310106587314, 614420757079213, 5799709014601124, 56530981389520624, 568255134674637557
Offset: 0

Author

Alois P. Heinz, Aug 21 2015

Keywords

Examples

			a(3) = 8: {}, 1, 2, 3, 1|2, 1|3, 2|3, 1|2|3.
a(4) = 25: {}, 1, 2, 3, 4, 1|2, 1|3, 13, 1|4, 2|3, 2|4, 24, 3|4, 1|2|3, 13|2, 1|2|4, 1|24, 1|3|4, 13|4, 2|3|4, 24|3, 1|2|3|4, 13|2|4, 1|3|24, 13|24.
		

Crossrefs

Programs

  • Maple
    g:= proc(n, l, t, f) option remember; `if`(n=0, 1,
          add(`if`(l>0 and j=l or f=1 and n=1 and j=1, 0,
          g(n-1, j, t+`if`(j=t, 1, 0), f)), j=0..t))
        end:
    a:= n-> `if`(n=0, 1, g(n-1, 0, 1, 0)+g(n-1, 1, 2, 1)):
    seq(a(n), n=0..25);
  • Mathematica
    g[n_, l_, t_, f_] := g[n, l, t, f] = If[n==0, 1, Sum[If[l>0 && j==l || f==1 && n==1 && j==1, 0, g[n-1, j, t+If[j==t, 1, 0], f]], {j, 0, t}]]; a[n_] := If[n==0, 1, g[n-1, 0, 1, 0]+g[n-1, 1, 2, 1]]; Table[a[n], {n, 0, 25}] (* Jean-François Alcover, Feb 02 2017, translated from Maple *)

A261492 Number of partitions of subsets of {1,...,n}, where consecutive integers are required to be in the same part and the elements of {1, n} are required to be in the same part if they are both members of a subset.

Original entry on oeis.org

1, 2, 4, 8, 18, 42, 102, 254, 648, 1688, 4486, 12146, 33474, 93810, 267112, 772124, 2264214, 6731254, 20275118, 61841886, 190914356, 596256556, 1883148834, 6012081046, 19395355770, 63205986042, 208003526516, 691048272152, 2317140259834, 7839542054210
Offset: 0

Author

Alois P. Heinz, Aug 21 2015

Keywords

Examples

			a(3) = 8: {}, 1, 2, 3, 12, 23, 13, 123.
a(4) = 18: {}, 1, 2, 3, 4, 12, 13, 1|3, 14, 23, 24, 2|4, 34, 123, 124, 134, 234, 1234.
		

Crossrefs

Programs

  • Maple
    with(combinat):
    a:= n-> `if`(n=0, 1, 2*add(binomial(n, 2*j)*bell(j), j=0..n/2)):
    seq(a(n), n=0..35);
  • Mathematica
    a[n_] := If[n==0, 1, 2*Sum[Binomial[n, 2*j]*BellB[j], {j, 0, n/2}]]; Table[ a[n], {n, 0, 35}] (* Jean-François Alcover, Feb 22 2017, translated from Maple *)

Formula

a(n) = 2 * Sum_{j=0..floor(n/2)} C(n,2*j) * A000110(j) for n>0, a(0) = 1.

A376077 Number of partitions of subsets of [n] containing n > 0, where consecutive integers are required to be in different parts.

Original entry on oeis.org

1, 1, 2, 6, 19, 68, 269, 1168, 5516, 28117, 153668, 895345, 5534292, 36137736, 248364343, 1790801964, 13508326353, 106329846806, 871423555238, 7420685528453, 65539734707912, 599363070599885, 5666859173305898, 55317197561841526, 556788566486730535
Offset: 0

Author

Alois P. Heinz, Sep 08 2024

Keywords

Examples

			a(3) = 6: 3, 13, 1|3, 2|3, 13|2, 1|2|3.
		

Crossrefs

Cf. A000045, A000110, A261041 (partial sums).

Programs

  • Maple
    b:= proc(n, m, i) option remember; `if`(n=0, 1, add(
         `if`(i=j and j>0, 0, b(n-1, max(m, j), j)), j=0..m+1))
        end:
    a:= n-> b(n, 0$2)-`if`(n>0, b(n-1, 0$2), 0):
    seq(a(n), n=0..30);
  • Mathematica
    b[n_, m_, i_] := b[n, m, i] = If[n == 0, 1, Sum[If[i == j && j > 0, 0, b[n-1, Max[m, j], j]], {j, 0, m+1}]];
    a[n_] := b[n, 0, 0] - If[n > 0, b[n-1, 0, 0], 0];
    Table[a[n], {n, 0, 30}] (* Jean-François Alcover, Sep 18 2024, after Alois P. Heinz *)

Formula

a(0) = 1, a(n) = A261041(n) - A261041(n-1) for n>=1.
G.f.: Sum_{j>=0} A000110(j) * (x/(1-x^2))^j.
Showing 1-9 of 9 results.