A233831
a(n) = -2*a(n-1) -2*a(n-2) + a(n-3). a(0) = -1, a(1) = 1, a(2) = 1.
Original entry on oeis.org
-1, 1, 1, -5, 9, -7, -9, 41, -71, 51, 81, -335, 559, -367, -719, 2731, -4391, 2601, 6311, -22215, 34409, -18077, -54879, 180321, -268961, 122401, 473441, -1460645, 2096809, -798887, -4056489, 11807561, -16301031, 4930451, 34548721, -95259375, 126351759
Offset: 0
G.f. = -1 + x + x^2 - 5*x^3 + 9*x^4 - 7*x^5 - 9*x^6 + 41*x^7 - 71*x^8 + ...
-
m:=50; R:=PowerSeriesRing(Integers(), m); Coefficients(R!((-1-x+x^2)/(1+2*x+2*x^2-x^3))); // G. C. Greubel, Aug 07 2018
-
CoefficientList[Series[(-1-x+x^2)/(1+2*x+2*x^2-x^3), {x, 0, 50}], x] (* G. C. Greubel, Aug 07 2018 *)
LinearRecurrence[{-2,-2,1},{-1,1,1},40] (* Harvey P. Dale, Nov 28 2024 *)
-
{a(n) = if( n<0, polcoeff( (-1 +3*x + x^2) / (1 - 2*x - 2*x^2 - x^3) + x * O(x^-n), -n), polcoeff( (-1 - x + x^2) / (1 + 2*x + 2*x^2 - x^3) + x * O(x^n), n))}
A287898
Number of ways to go up and down n stairs, with fewer than 4 stairs at a time, stepping on each stair at least once.
Original entry on oeis.org
1, 3, 9, 27, 79, 233, 687, 2025, 5969, 17595, 51865, 152883, 450655, 1328401, 3915743, 11542481, 34023905, 100292659, 295633833, 871443275, 2568763439, 7571973753, 22319994767, 65792907193, 193938514865, 571674807403, 1685132453689, 4967284459107
Offset: 1
n = 2
0->1->2->0 (0), 0->2->1->0 (1), 0->1->2->1->0 (2). So a(2) = 3.
n = 3
0->1->2->3->0 (00), 0->1->3->2->0 (01), 0->1->2->3->2->0 (02),
0->2->3->1->0 (10), 0->3->2->1->0 (11), 0->2->3->2->1->0 (12),
0->1->2->3->1->0 (20), 0->1->3->2->1->0 (21), 0->1->2->3->2->1->0 (22). So a(3) = 9.
...
n = 5
0->1->2->3->5->4->0 (0001), ... , 0->4->5->3->2->1->0 (1110),
0->4->5->4->3->2->1->0 (1112), ... , 0->1->2->3->4->5->4->3->2->1->0 (2222).
So a(5) = 81 - 2 = 79.
-
CoefficientList[Series[(1 + x)*(1 + x^2)/(1 - 2*x - 2*x^2 - 2*x^3 - x^4), {x, 0, 30}], x] (* Wesley Ivan Hurt, Jun 02 2017 *)
-
Vec(x*(1 + x)*(1 + x^2) / (1 - 2*x - 2*x^2 - 2*x^3 - x^4) + O(x^30)) \\ Colin Barker, Jun 02 2017
-
def f(ary, n)
return false if ary.size < n
a = ary[-1]
ary[-n..-2].all?{|i| i == a}
end
def A(k, n)
f_ary = [[]]
ary = [1]
(n - 1).times{
b_ary = []
f_ary.each{|i|
i0, i1, i2 = i + [0], i + [1], i + [2]
b_ary << i0 if !f(i0, k)
b_ary << i1 if !f(i1, k)
b_ary << i2
}
f_ary = b_ary
ary << f_ary.size
}
ary
end
p A(4, 10)
Showing 1-2 of 2 results.
Comments