A068912 Number of n step walks (each step +/-1 starting from 0) which are never more than 3 or less than -3.
1, 2, 4, 8, 14, 28, 48, 96, 164, 328, 560, 1120, 1912, 3824, 6528, 13056, 22288, 44576, 76096, 152192, 259808, 519616, 887040, 1774080, 3028544, 6057088, 10340096, 20680192, 35303296, 70606592, 120532992, 241065984, 411525376, 823050752, 1405035520, 2810071040
Offset: 0
Links
- T. Mansour and A. O. Munagi, Alternating subsets modulo m, Rocky Mt. J. Math. 42, No. 4, 1313-1325 (2012), Table 1 q=(0,1,1,1).
- Index entries for linear recurrences with constant coefficients, signature (0,4,0,-2).
Programs
-
Maple
# From Peter Luschny, Sep 20 2020: (Start) r := 1 + 2^(1/2): s := 1 - 2^(1/2): c := n -> (1+r)^(n/2)*(r+(2*(1+r))^(1/2)+(-1)^n*(r-(2*(1+r))^(1/2))): b := n -> (1+s)^(n/2)*(s-(2*(1+s))^(1/2)+(-1)^n*(s+(2*(1+s))^(1/2))): a := n -> (c(n) + b(n))/4: # Alternatively: a := proc(n) local h; h := n -> add((1+x)*(2+x)^(n/2), x=[sqrt(2),-sqrt(2)]); if n::even then h(n)/2 else h(n-1) fi end: seq(simplify(a(n)), n=0..30); # (End)
-
Mathematica
nn=33; CoefficientList[Series[s+a + b + c + d + e +f/.Solve[{s ==1 + x a + x b, a==x s + x c, b==x s +x d, c==x a +x e, d== x b + x f, e==x c, f==x d,z==x e + x f },{s,a,b,c,d,e,f,z}],{x,0,nn}],x] (* Geoffrey Critzer, Jan 13 2014 *) a[n_,k_]:=2^n /(k+1) Sum[(-1)^r Cos[(Pi (2r-1))/(2 (k+1))]^n Cot[(Pi (1-2r))/(4 (k+1))] ,{r,1,k+1}] Table[a[n,3],{n,0,40}]//Round (* Herbert Kociemba, Sep 19 2020 *) a[n_]:=Module[{r=2+Sqrt[2]},Floor[(r^(n/2) (-2 (-1+(-1)^n) Sqrt[r]+(1+(-1)^n) r))/(4 Sqrt[2])]] Table[a[n],{n,0,40}] (* Herbert Kociemba, Sep 21 2020 *)
Formula
G.f.: (1+2*x)/(1-4*x^2+2*x^4).
a(n) = A068913(3, n).
a(n) = 4*a(n-2) - 2*a(n-4).
a(n) = (2^n/4)*Sum_{r=1..4} (-1)^r*cos((Pi*(2*r-1))/8)^n*cot((Pi*(1-2*r))/16). - Herbert Kociemba, Sep 19 2020
Conjecture: a(n) = floor((1+r)^(n/2)*(r+(2*(1+r))^(1/2)+(-1)^n*(r-(2*(1+r))^(1/2)))/4) where r = 1 + 2^(1/2). - Peter Luschny, Sep 20 2020
From Herbert Kociemba, Sep 20 2020: (Start)
With the standard procedure to obtain an explicit formula for a(n) for a linear recurrence and r1=2-sqrt(2) and r2=2+sqrt(2) we get
a(n) = a1(n) + a2(n) with
a1(n) = -(r1^(n/2)*(-2*(-1+(-1)^n)*sqrt(r1)+(1+(-1)^n)*r1))/(4*sqrt(2)) and
a2(n) = +(r2^(n/2)*(-2*(-1+(-1)^n)*sqrt(r2)+(1+(-1)^n)*r2))/(4*sqrt(2)).
We have -1
A077846 Expansion of g.f. 1/(1 - 3*x + 2*x^3).
1, 3, 9, 25, 69, 189, 517, 1413, 3861, 10549, 28821, 78741, 215125, 587733, 1605717, 4386901, 11985237, 32744277, 89459029, 244406613, 667731285, 1824275797, 4984014165, 13616579925, 37201188181, 101635536213, 277673448789, 758617970005, 2072582837589, 5662401615189
Offset: 0
Comments
Number of (s(0), s(1), ..., s(n+2)) such that 0 < s(i) < 6 and |s(i) - s(i-1)| <= 1 for i = 1..n+2, s(0) = 1, s(n+2) = 3. - Herbert Kociemba, Jun 17 2004
A Whitney transform of 2^n (see Benoit Cloitre formula and A004070). The Whitney transform maps the sequence with g.f. g(x) to that with g.f. (1/(1-x))g(x(1+x)). - Paul Barry, Feb 16 2005
Links
- Vincenzo Librandi, Table of n, a(n) for n = 0..1000
- Fan Chung and R. L. Graham, Primitive juggling sequences, Am. Math. Monthly 115 (3) (2008) 185-194.
- William J. Keith, Partitions into parts simultaneously regular, distinct, and/or flat, Proceedings of CANT 2016; arXiv:1911.04755 [math.CO], 2019. Mentions this sequence.
- Yassine Otmani, The 2-Pascal Triangle and a Related Riordan Array, J. Int. Seq. (2025) Vol. 28, Issue 3, Art. No. 25.3.5. See p. 12.
- Index entries for linear recurrences with constant coefficients, signature (3,0,-2).
Programs
-
Mathematica
CoefficientList[Series[1 / (1 - 3 x + 2 x^3), {x, 0, 40}], x] (* Vincenzo Librandi, Jun 19 2013 *) LinearRecurrence[{3,0,-2},{1,3,9},40] (* Harvey P. Dale, Apr 27 2014 *)
-
PARI
a(n)=sum(i=0,n,sum(j=0,n,2^j*binomial(j,i-j)))
-
PARI
Vec(1/(1-3*x+2*x^3) + O(x^100)) \\ Altug Alkan, Mar 24 2016
Formula
a(n) = 3*a(n-1) - 2*a(n-3) = 2*A057960(n) - 1 = round(2*A028859(n)/sqrt(3) - 1/3) = Sum_{i} b(n, i), where b(n, 0) = b(n, 6) = 0, b(0, 3) = 1, b(0, i) = 0 if i <> 3 and b(n+1, i) = b(n, i-1) + b(n, i) + b(n, i+1) if 0 < i < 6 (i.e., the number of three-choice paths along a corridor width 5, starting from the middle). - Henry Bottomley, Mar 06 2003
Binomial transform of A068911. a(n) = (1+sqrt(3))^n*(2+sqrt(3))/3 + (1-sqrt(3))^n*(2-sqrt(3))/3 - 1/3. - Paul Barry, Feb 17 2004
a(0)=1; for n >= 1, a(n) = ceiling((1+sqrt(3))*a(n-1)). - Benoit Cloitre, Jun 19 2004
a(n) = Sum_{i=0..n} Sum_{j=0..n} 2^j*binomial(j, i-j). - Benoit Cloitre, Oct 23 2004
a(n) = 2*(a(n-1) + a(n-2)) + 1, n > 1. - Gary Detlefs, Jun 20 2010
a(n) = (2*A052945(n+1) - 1)/3. - R. J. Mathar, Mar 31 2011
a(n) = floor((1+sqrt(3))^(n+2)/6). - Bruno Berselli, Feb 05 2013
a(n) = (-2 + (1-sqrt(3))^(n+2) + (1+sqrt(3))^(n+2))/6. - Alexander R. Povolotsky, Feb 13 2016
E.g.f.: exp(x)*(4*cosh(sqrt(3)*x) + 2*sqrt(3)*sinh(sqrt(3)*x) - 1)/3. - Stefano Spezia, Mar 02 2024
Extensions
Name changed by Arkadiusz Wesolowski, Dec 06 2011
A216212 Number of n step walks (each step +-1 starting from 0) which are never more than 4 or less than -4.
1, 2, 4, 8, 16, 30, 60, 110, 220, 400, 800, 1450, 2900, 5250, 10500, 19000, 38000, 68750, 137500, 248750, 497500, 900000, 1800000, 3256250, 6512500, 11781250, 23562500, 42625000, 85250000, 154218750, 308437500, 557968750, 1115937500, 2018750000, 4037500000
Offset: 0
Comments
The number of n step walks (each step +-1 starting from 0) which are never more than k or less than -k is given by a(n,k) = 2^n/(k+1)*Sum_{r=1..k+1} (-1)^r*cos((Pi*(2*r-1))/(2*(k+1)))^n*cot((Pi*(1-2*r))/(4*(k+1))), n<>0 if k even. Here we have k=4. - Herbert Kociemba, Sep 22 2020
Links
- Index entries for linear recurrences with constant coefficients, signature (0,5,0,-5).
Programs
-
Mathematica
nn=30;CoefficientList[Series[(1+x-x^2)^2/(1-5x^2+5x^4),{x,0,nn}],x] (* Geoffrey Critzer, Jan 14 2014 *) a[0,4]=1; a[n_,k_]:=2^n/(k+1) Sum[(-1)^r Cos[(Pi (2r-1))/(2 (k+1))]^n Cot[(Pi (1-2r))/(4 (k+1))],{r,1,k+1}] Table[a[n,4],{n,0,40}]//Round (* Herbert Kociemba, Sep 22 2020 *)
Formula
a(n) = A068913(4,n).
G.f.: (1+2*x-x^2-2*x^3+x^4)/(1-5*x^2+5*x^4).
a(n) = 5*a(n-2) - 5*a(n-4), a(0) = 1, a(1) = 2, a(2) = 4, a(3) = 8, a(4) = 16.
a(n) = (2^n/5)*Sum_{r=1..5} (-1)^r*cos(Pi*(2*r-1)/10)^n*cot(Pi*(1-2*r)/20), n>0. - Herbert Kociemba, Sep 22 2020
A365825 Number of integer partitions of n that are not of length 2 and do not contain n/2.
1, 1, 1, 2, 2, 5, 6, 12, 14, 26, 31, 51, 61, 95, 114, 169, 202, 289, 347, 481, 576, 782, 936, 1244, 1487, 1946, 2323, 2997, 3570, 4551, 5414, 6827, 8103, 10127, 11997, 14866, 17575, 21619, 25507, 31166, 36692, 44563, 52362, 63240, 74152, 89112, 104281, 124731
Offset: 0
Keywords
Comments
Also the number of integer partitions of n with no two possibly equal parts summing to n.
Examples
The a(1) = 1 through a(8) = 14 partitions: (1) (2) (3) (4) (5) (6) (7) (8) (111) (1111) (221) (222) (322) (332) (311) (411) (331) (521) (2111) (2211) (421) (611) (11111) (21111) (511) (2222) (111111) (2221) (3221) (3211) (3311) (4111) (5111) (22111) (22211) (31111) (32111) (211111) (221111) (1111111) (311111) (2111111) (11111111)
Crossrefs
The complement is counted by A238628.
Programs
-
Mathematica
Table[Length[Select[IntegerPartitions[n],Length[#]!=2&&FreeQ[#,n/2]&]],{n,0,15}]
-
Python
from sympy import npartitions def A365825(n): return npartitions(n)-(m:=n>>1)-(0 if n&1 else npartitions(m)-1) # Chai Wah Wu, Sep 23 2023
Formula
Extensions
a(31)-a(47) from Chai Wah Wu, Sep 23 2023
A366131 Number of subsets of {1..n} with two elements (possibly the same) summing to n.
0, 0, 2, 2, 10, 14, 46, 74, 202, 350, 862, 1562, 3610, 6734, 14926, 28394, 61162, 117950, 249022, 484922, 1009210, 1979054, 4076206, 8034314, 16422922, 32491550, 66045982, 131029082, 265246810, 527304974, 1064175886, 2118785834, 4266269482, 8503841150, 17093775742, 34101458042, 68461196410, 136664112494
Offset: 0
Examples
The a(0) = 0 through a(5) = 14 subsets: . . {1} {1,2} {2} {1,4} {1,2} {1,2,3} {1,2} {2,3} {1,3} {1,2,3} {2,3} {1,2,4} {2,4} {1,3,4} {1,2,3} {1,4,5} {1,2,4} {2,3,4} {1,3,4} {2,3,5} {2,3,4} {1,2,3,4} {1,2,3,4} {1,2,3,5} {1,2,4,5} {1,3,4,5} {2,3,4,5} {1,2,3,4,5}
Links
- Index entries for linear recurrences with constant coefficients, signature (2,3,-6).
Crossrefs
Programs
-
Mathematica
Table[Length[Select[Subsets[Range[n]],MemberQ[Total/@Tuples[#,2],n]&]],{n,0,10}]
-
Python
def A366131(n): return (1<
>1)<<1) if n else 0 # Chai Wah Wu, Nov 14 2023
Formula
From Chai Wah Wu, Nov 14 2023: (Start)
a(n) = 2*a(n-1) + 3*a(n-2) - 6*a(n-3) for n > 3.
G.f.: 2*x^2*(1 - x)/((2*x - 1)*(3*x^2 - 1)). (End)
A060647 Number of alpha-beta evaluations in a tree of depth n and branching factor b=3.
1, 3, 5, 11, 17, 35, 53, 107, 161, 323, 485, 971, 1457, 2915, 4373, 8747, 13121, 26243, 39365, 78731, 118097, 236195, 354293, 708587, 1062881, 2125763, 3188645, 6377291, 9565937, 19131875, 28697813, 57395627, 86093441, 172186883, 258280325, 516560651, 774840977
Offset: 0
Examples
a(2n+1) = 2*a(2n) + 1, a(15) = a(2*7+1) = 2*a(14) + 1 = 2*4373 + 1 = 8747.
References
- P. H. Winston, Artificial Intelligence, Addison-Wesley, 1977, pp. 115-122, (alpha-beta technique).
Links
- Harry J. Smith, Table of n, a(n) for n = 0..500
- Index entries for linear recurrences with constant coefficients, signature (1, 3, -3).
Programs
-
Maple
A060647 := proc(n,b) option remember: if n mod 2 = 0 then RETURN(2*b^(n/2)-1) else RETURN(b^((n-1)/2) +b^((n+1)/2)-1) fi: end: for n from 0 to 60 do printf(`%d,`, A060647(n,3)) od: a[0]:=1:a[1]:=3:for n from 2 to 100 do a[n]:=3*a[n-2]+2 od: seq(a[n], n=0..33); # Zerinvary Lajos, Mar 17 2008
-
Mathematica
f[n_] := Simplify[Sqrt[3]^n(1 + 2/Sqrt[3]) + (1 - 2/Sqrt[3])(-Sqrt[3])^n - 1]; Table[ f[n], {n, 0, 34}] (* or *) f[n_] := If[ EvenQ[n], 2(3^(n/2)) - 1, 3^((n - 1)/2) + 3^((n + 1)/2) - 1]; Table[ f[n], {n, 0, 34}] (* or *) CoefficientList[ Series[(1 + 2x - x^2)/((1 - x)(1 - 3x^2)), {x, 0, 35}], x] (* Robert G. Wilson v, Nov 17 2005 *)
-
PARI
a(n) = { if (n%2==0, 2*(3^(n/2)) - 1, my(m=(n - 1)/2); 3^m + 3^(m + 1) - 1) } \\ Harry J. Smith, Jul 09 2009
Formula
a(2n) = 2*(3^n) - 1, a(2n+1) = 3^n + 3^(n+1) - 1.
Formula for b branches: a(2n) = 2*(b^n)-1, a(2n+1) = b^n+b^(n+1)-1.
a(n) = A068911(n+1) - 1.
G.f.: (1+2*z-z^2)/((1-z)*(1-3*z^2)). - Emeric Deutsch, Nov 18 2002
a(n) = (sqrt(3))^n(1+2/sqrt(3))+(1-2/sqrt(3))(-sqrt(3))^n-1. - Paul Barry, Apr 17 2004
a(2n+1) = 3*a(2n-1) + 2; a(2n) = (a(2n-1) + a(2n+1))/2, with a(1)= 1. See A062318 for case where a(1)= 0.
a(n) = (2^((1+(-1)^n)/2))*(b^((2*n-1+(-1)^n)/4))+((1-(-1)^n)/2)*(b^((2*n+1-(-1)^n)/4))-1, with b=3. - Luce ETIENNE, Aug 30 2014
Extensions
More terms from James Sellers, Apr 19 2001
A306293 Number of binary words of length n such that in every prefix and in every suffix the number of 0's and the number of 1's differ by at most two.
1, 2, 4, 6, 10, 16, 26, 42, 70, 110, 194, 288, 550, 754, 1586, 1974, 4630, 5168, 13634, 13530, 40390, 35422, 120146, 92736, 358390, 242786, 1071074, 635622, 3205030, 1664080, 9598706, 4356618, 28763350, 11405774, 86224514, 29860704, 258542470, 78176338
Offset: 0
Comments
All terms with index n > 0 are even.
Examples
a(3) = 6: 001, 010, 011, 100, 101, 110. a(4) = 10: 0010, 0011, 0100, 0101, 0110, 1001, 1010, 1011, 1100, 1101. a(5) = 16: 00101, 00110, 01001, 01010, 01011, 01100, 01101, 01110, 10001, 10010, 10011, 10100, 10101, 10110, 11001, 11010. a(6) = 26: 001010, 001011, 001100, 001101, 001110, 010010, 010011, 010100, 010101, 010110, 011001, 011010, 011100, 100011, 100101, 100110, 101001, 101010, 101011, 101100, 101101, 110001, 110010, 110011, 110100, 110101. a(7) = 42: 0010101, 0010110, 0011001, ..., 1100110, 1101001, 1101010. a(8) = 70: 00101010, ..., 00111100, ..., 11000011, ..., 11010101.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..4193
- Index entries for linear recurrences with constant coefficients, signature (0,8,0,-22,0,23,0,-6).
Crossrefs
Programs
-
Maple
a:= n-> `if`(n<2, 1+n, 2*(<<0|1|0|0>, <0|0|1|0>, <0|0|0|1>, <-6|23|-22|8>>^iquo(n-2, 2, 'r').[<<2, 5, 13, 35>>, <<3, 8, 21, 55>>][1+r])[1, 1]): seq(a(n), n=0..50);
Formula
G.f.: -(x+1)*(4*x^7-4*x^6-7*x^5-5*x^4+5*x^3+5*x^2-x-1) / ((3*x^2-1) *(2*x^2-1) *(x^2+x-1) *(x^2-x-1)).
a(n) <= A306306(n).
A366130 Number of subsets of {1..n} with a subset summing to n + 1.
0, 0, 1, 2, 7, 15, 38, 79, 184, 378, 823, 1682, 3552, 7208, 14948, 30154, 61698, 124302, 252125, 506521, 1022768, 2051555, 4127633, 8272147, 16607469, 33258510, 66680774, 133467385, 267349211, 535007304, 1071020315, 2142778192, 4288207796
Offset: 0
Examples
The subset S = {1,2,4} has subset {1,4} with sum 4+1 and {2,4} with sum 5+1 and {1,2,4} with sum 6+1, so S is counted under a(4), a(5), and a(6). The a(0) = 0 through a(5) = 15 subsets: . . {1,2} {1,3} {1,4} {1,5} {1,2,3} {2,3} {2,4} {1,2,3} {1,2,3} {1,2,4} {1,2,4} {1,3,4} {1,2,5} {2,3,4} {1,3,5} {1,2,3,4} {1,4,5} {2,3,4} {2,4,5} {1,2,3,4} {1,2,3,5} {1,2,4,5} {1,3,4,5} {2,3,4,5} {1,2,3,4,5}
Crossrefs
Programs
-
Mathematica
Table[Length[Select[Subsets[Range[n]],MemberQ[Total/@Subsets[#],n+1]&]],{n,0,10}]
-
Python
from itertools import combinations from sympy.utilities.iterables import partitions def A366130(n): a = tuple(set(p.keys()) for p in partitions(n+1,k=n) if max(p.values(),default=0)==1) return sum(1 for k in range(2,n+1) for w in (set(d) for d in combinations(range(1,n+1),k)) if any(s<=w for s in a)) # Chai Wah Wu, Nov 24 2023
Formula
Diagonal k = n + 1 of A365381.
Extensions
a(20)-a(32) from Chai Wah Wu, Nov 24 2023
A216241 Number of n-step walks (each step +-1 starting from 0) which are never more than 5 or less than -5.
1, 2, 4, 8, 16, 32, 62, 124, 236, 472, 890, 1780, 3340, 6680, 12502, 25004, 46732, 93464, 174554, 349108, 651740, 1303480, 2432918, 4865836, 9080956, 18161912, 33892954, 67785908, 126494956, 252989912, 472095062, 944190124, 1761901676, 3523803352, 6575544410, 13151088820
Offset: 0
Crossrefs
Programs
-
Mathematica
nn=35;CoefficientList[Series[(1+2x)(1-x^2)^2/(1-6x^2+9x^4-2x^6),{x,0,nn}],x] (* Geoffrey Critzer, Jan 14 2014 *)
Formula
a(n) = A068913(5,n).
a(n) = 6*a(n-2) - 9*a(n-4) + 2*a(n-6).
a(n) = 2^n for n < 6.
G.f.: ((1-x)^2*(1+x)^2*(1+2*x)) / ((1-2*x^2)*(1-4*x^2+x^4)).
a(2*n+1) = 2*a(2*n).
a(n) = Sum_{k=0..n} A214846(n-k, k). - Philippe Deléham, Mar 25 2013
Extensions
a(34) corrected by Sean A. Irvine, May 19 2019
A228879 a(n+2) = 3*a(n), starting 4,7.
4, 7, 12, 21, 36, 63, 108, 189, 324, 567, 972, 1701, 2916, 5103, 8748, 15309, 26244, 45927, 78732, 137781, 236196, 413343, 708588, 1240029, 2125764, 3720087, 6377292, 11160261, 19131876, 33480783, 57395628, 100442349, 172186884, 301327047, 516560652
Offset: 0
Comments
Successive terms are the square roots of expressions of prior terms. The same recursive formula (see below) can be applied using any term of A001353 as the initializing value to produce the family of sequences, as given in the array A227418. This sequence uses A001353(2) = 4, and is the third row of that array.
a(4n) are the squares of A008776(n).
Binomial transform of a(n) is A021006.
First differences of a(n) = A083658 (without initial two terms).
2nd differences of a(n) = A068911 (with initial term).
a(n-1) is the number of n-digit base 10 numbers where all the digits are even numbers, and each digit differs by 2 from the previous and the next digit. - Graeme McRae, Jun 09 2014
Links
- Paolo Xausa, Table of n, a(n) for n = 0..1000
- Twitter / MathQuizzes, Puzzle relating to this sequence
- Index entries for linear recurrences with constant coefficients, signature (0,3).
Programs
-
Mathematica
LinearRecurrence[{0, 3}, {4, 7}, 50] (* Paolo Xausa, Oct 14 2024 *)
-
PARI
Vec(-(7*x+4)/(3*x^2-1) + O(x^100)) \\ Colin Barker, Jun 09 2014
Formula
a(n) = sqrt(3*a(n-1)^2 + (-3)^(n-1)), a(0) = 4.
This divisibility relation also applies: a(n+3) = a(n+2)*a(n+1)/a(n).
G.f.: -(7*x+4) / (3*x^2-1). - Colin Barker, Jun 09 2014
From Stefano Spezia, Mar 20 2022: (Start)
a(n) = 3^((n-1)/2)*(4*sqrt(3) + 7 + (-1)^n*(4*sqrt(3) - 7))/2.
E.g.f.: 4*cosh(sqrt(3)*x) + 7*sinh(sqrt(3)*x)/sqrt(3). (End)
Extensions
More terms from Colin Barker, Jun 09 2014
Comments