login
A131183
a(n) = a(n-1) + a(n-2) if n == 3 mod 4; a(n) = a(n-1) - a(n-2) if n == 0 mod 4; a(n) = a(n-1)*a(n-2) if n == 1 mod 4; and a(n) = a(n-1)/a(n-2) if n == 2 mod 4; with a(1)=a(2)=1.
2
1, 1, 2, 1, 2, 2, 4, 2, 8, 4, 12, 8, 96, 12, 108, 96, 10368, 108, 10476, 10368, 108615168, 10476, 108625644, 108615168, 11798392572168192, 108625644, 11798392680793836, 11798392572168192, 139202068568601556987554268864512
OFFSET
1,3
COMMENTS
If S(n)=a(4n-1) (i.e., term "+"), R(n)=a(4n) (i.e., "-"), P(n)=a(4n+1), D(n)=a(4n+2) then D(n)=S(n), P(n)=S(n+1)-S(n), R(n+1)=P(n)=S(n+1)-S(n). - Jose Ramon Real, Nov 10 2007
EXAMPLE
a(3) = a(2) + a(1) = 1 + 1 = 2;
a(4) = a(3) - a(2) = 2 - 1 = 1;
a(5) = a(4) * a(3) = 1 * 2 = 2;
a(6) = a(5) / a(4) = 2 / 1 = 2.
MAPLE
A131183 := proc(n) option remember ; if n <= 2 then 1 ; elif n mod 4 = 3 then A131183(n-1)+A131183(n-2) ; elif n mod 4 = 0 then A131183(n-1)-A131183(n-2) ; elif n mod 4 = 1 then A131183(n-1)*A131183(n-2) ; else A131183(n-1)/A131183(n-2) ; fi ; end: seq(A131183(n), n=1..35) ; # R. J. Mathar, Oct 28 2007
MATHEMATICA
a[1]=a[2]=1; a[n_] := a[n] = Switch[Mod[n, 4], 3, a[n-1]+a[n-2], 0, a[n-1]-a[n-2], 1, a[n-1]*a[n-2], 2, a[n-3]]; Array[a, 30] (* Jean-François Alcover, Dec 28 2015 *)
nxt[{n_, a_, b_}]:=Module[{m=Mod[n+1, 4]}, {n+1, b, Which[m==3, a+b, m==0, b-a, m==1, a*b, m==2, b/a]}]; Join[{1, 1, 2}, NestList[nxt, {1, 1, 2}, 30][[All, 2]]] (* Harvey P. Dale, Sep 04 2017 *)
CROSSREFS
Sequence in context: A225530 A020475 A156995 * A346063 A133770 A288310
KEYWORD
easy,nonn
AUTHOR
Jose Ramon Real, Oct 22 2007
EXTENSIONS
More terms from R. J. Mathar, Oct 28 2007
STATUS
approved