login
A261038
a(1)=1; for n>1: a(n) = a(n-1)*n if t=0, a(n) = round(a(n-1)/n) if t=1, a(n) = a(n-1)+n if t=2, a(n) = a(n-1)-n if t=3, where t = n mod 4.
1
1, 3, 0, 0, 0, 6, -1, -8, -1, 9, -2, -24, -2, 12, -3, -48, -3, 15, -4, -80, -4, 18, -5, -120, -5, 21, -6, -168, -6, 24, -7, -224, -7, 27, -8, -288, -8, 30, -9, -360, -9, 33, -10, -440, -10, 36, -11, -528, -11, 39, -12, -624, -12, 42, -13, -728, -13, 45, -14
OFFSET
1,2
COMMENTS
a(4*n+1) = 1, 0, -1, -2, -3, ...
a(4*n+2) = 3, 6, 9, 12, 15, ...
a(4*n+3) = 0, -1, -2, -3, -4, ...
a(4*n+4) = 0, -8, -24, -48, -80, ... = -A033996(n).
LINKS
FORMULA
From Colin Barker, Aug 09 2015: (Start)
a(n) = 3*a(n-4) - 3*a(n-8) + a(n-12).
G.f.: -x*(x^10+2*x^8-8*x^7-x^6-3*x^5-3*x^4+3*x+1) / ((x-1)^3*(x+1)^3*(x^2+1)^3).
(End)
EXAMPLE
a(1) = 1.
a(2) = a(1) + 2 = 3.
a(3) = a(2) - 3 = 0.
a(4) = a(3) * 4 = 0.
a(5) = round(a(4) / 5) = 0.
a(6) = a(5) + 6 = 6.
a(7) = a(6) - 7 = -1.
MAPLE
a:= proc(n) option remember; `if`(n=1, 1, (t->
`if`(t=0, a(n-1)*n, `if`(t=1, round(a(n-1)/n),
`if`(t=2, a(n-1)+n, a(n-1)-n))))(irem(n, 4)))
end:
seq(a(n), n=1..100); # Alois P. Heinz, Aug 08 2015
MATHEMATICA
nxt[{n_, a_}]:=Module[{t=Mod[n+1, 4]}, {n+1, Which[t==0, a(n+1), t==1, Round[ a/(n+1)], t==2, a+n+1, t==3, a-n-1]}]; NestList[nxt, {1, 1}, 100][[All, 2]] (* or *) LinearRecurrence[{0, 0, 0, 3, 0, 0, 0, -3, 0, 0, 0, 1}, {1, 3, 0, 0, 0, 6, -1, -8, -1, 9, -2, -24}, 100] (* Harvey P. Dale, May 25 2018 *)
PROG
(PARI) Vec(-x*(x^10+2*x^8-8*x^7-x^6-3*x^5-3*x^4+3*x+1)/((x-1)^3*(x+1)^3*(x^2+1)^3) + O(x^100)) \\ Colin Barker, Aug 10 2015
(PARI) first(m)=my(v=vector(m), t); v[1]=1; for(i=2, m, t = i%4; if(t==0, v[i]=v[i-1]*i, if(t==1, v[i]=round(v[i-1]/i), if(t==2, v[i]=v[i-1]+i, v[i]=v[i-1]-i )))); v; \\ Anders Hellström, Aug 17 2015
CROSSREFS
Cf. A033996.
Sequence in context: A327889 A221702 A084681 * A370108 A285852 A096528
KEYWORD
sign,easy
AUTHOR
Peter Woodward, Aug 07 2015
EXTENSIONS
More terms from Alois P. Heinz, Aug 08 2015
Edited by Jon E. Schoenfield, Aug 08 2015
Corrected by Harvey P. Dale, May 25 2018
STATUS
approved