OFFSET
1,2
COMMENTS
In general, for sequences that multiply the first k natural numbers, and then add the product of the next k natural numbers (preserving the order of operations up to n), we have a(n) = Sum_{i=1..floor(n/k)} (k*i)!/(k*i-k)! + Sum_{j=1..k-1} (1-sign((n-j) mod k)) * (Product_{i=1..j} n-i+1). Here, k=4.
LINKS
Colin Barker, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,0,0,5,-5,0,0,-10,10,0,0,10,-10,0,0,-5,5,0,0,1,-1).
FORMULA
a(n) = Sum_{i=1..floor(n/4)} (4*i)!/(4*i-4)! + Sum_{j=1..3} (1-sign((n-j) mod 4)) * (Product_{i=1..j} n-i+1).
From Colin Barker, Sep 14 2018: (Start)
G.f.: x*(1 + x + 4*x^2 + 18*x^3 + 20*x^5 + 160*x^6 + 1380*x^7 - 6*x^8 - 34*x^9 + 40*x^10 + 3720*x^11 + 8*x^12 + 4*x^13 - 192*x^14 + 1020*x^15 - 3*x^16 + 9*x^17 - 12*x^18 + 6*x^19) / ((1 - x)^6*(1 + x)^5*(1 + x^2)^5).
a(n) = a(n-1) + 5*a(n-4) - 5*a(n-5) - 10*a(n-8) + 10*a(n-9) + 10*a(n-12) - 10*a(n-13) - 5*a(n-16) + 5*a(n-17) + a(n-20) - a(n-21) for n>21.
(End)
EXAMPLE
a(1) = 1;
a(2) = 1*2 = 2;
a(3) = 1*2*3 = 6;
a(4) = 1*2*3*4 = 24;
a(5) = 1*2*3*4 + 5 = 29;
a(6) = 1*2*3*4 + 5*6 = 54;
a(7) = 1*2*3*4 + 5*6*7 = 234;
a(8) = 1*2*3*4 + 5*6*7*8 = 1704;
a(9) = 1*2*3*4 + 5*6*7*8 + 9 = 1713;
a(10) = 1*2*3*4 + 5*6*7*8 + 9*10 = 1794;
a(11) = 1*2*3*4 + 5*6*7*8 + 9*10*11 = 2694;
a(12) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 = 13584;
a(13) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13 = 13597;
a(14) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13*14 = 13766;
a(15) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13*14*15 = 16314;
a(16) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13*14*15*16 = 57264;
a(17) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13*14*15*16 + 17 = 57281;
a(18) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13*14*15*16 + 17*18 = 57570;
a(19) = 1*2*3*4 + 5*6*7*8 + 9*10*11*12 + 13*14*15*16 + 17*18*19 = 63078;
etc.
MATHEMATICA
a[n_]:=Sum[(4*i)!/(4*i-4)!, {i, 1, Floor[n/4] }] + Sum[(1-Sign[Mod[n-j, 4]])*Product[n-i+1, {i, 1, j}], {j, 1, 3}] ; Array[a, 40] (* Stefano Spezia, Sep 17 2018 *)
PROG
(PARI) Vec(x*(1 + x + 4*x^2 + 18*x^3 + 20*x^5 + 160*x^6 + 1380*x^7 - 6*x^8 - 34*x^9 + 40*x^10 + 3720*x^11 + 8*x^12 + 4*x^13 - 192*x^14 + 1020*x^15 - 3*x^16 + 9*x^17 - 12*x^18 + 6*x^19) / ((1 - x)^6*(1 + x)^5*(1 + x^2)^5) + O(x^40)) \\ Colin Barker, Sep 14 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Wesley Ivan Hurt, Sep 13 2018
STATUS
approved