A248479 a(1) = 1, a(2) = 3, and from then on alternatively subtract and multiply two previous terms.
1, 3, 2, 6, 4, 24, 20, 480, 460, 220800, 220340, 48651072000, 48650851660, 2366916086971979520000, 2366916086923328668340, 5602291762651594835806920193095352396800000, 5602291762651594835804553277008429068131660, 31385672993873913406017018916292673201543291913142263413575757282059524278962688000000
Offset: 1
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..25
Programs
-
Haskell
a248479 n = a248479_list !! (n-1) a248479_list = 1 : 3 : zipWith ($) (map uncurry $ cycle [(-), (*)]) (zip (tail a248479_list) a248479_list) -- Reinhard Zumkeller, Oct 28 2014
-
Maple
a:= proc(n) option remember; piecewise(n::odd, a(n-1)-a(n-2), a(n-1)*a(n-2)) end proc: a(1):= 1: a(2):= 3: seq(a(n),n=1..20); # Robert Israel, Oct 27 2014
-
Mathematica
nxt[{n_,a_,b_}]:={n+1,b,If[EvenQ[n],b-a,b*a]}; NestList[nxt,{2,1,3},20][[All,2]] (* Harvey P. Dale, Jul 31 2018 *)
-
PARI
v=[1,3];for(n=1,20,if(n%2,v=concat(v,v[#v]-v[#v-1]));if(!(n%2),v=concat(v,v[#v]*v[#v-1])));v \\ Derek Orr, Oct 26 2014
-
Scheme
(definec (A248479 n) (cond ((= 1 n) 1) ((= 2 n) 3) ((odd? n) (- (A248479 (- n 1)) (A248479 (- n 2)))) (else (* (A248479 (- n 1)) (A248479 (- n 2)))))) ;; A memoizing definec-macro can be found from http://oeis.org/wiki/Memoization - Antti Karttunen, Oct 26 2014
Formula
a(1) = 1, a(2) = 3, after which, when n is odd, a(n) = a(n-1) - a(n-2), and when n is even, a(n) = a(n-1) * a(n-2). - Antti Karttunen, Oct 26 2014, after the comment of original author.
a(n) = (a(n-1)*a(n-2) + a(n-1) - a(n-2) + (-1)^n * (a(n-1)*a(n-2) - a(n-1) + a(n-2)))/2. - Robert Israel, Oct 27 2014
Extensions
One term corrected and additional terms added by Colin Barker, Oct 07 2014
Term a(18) added by Antti Karttunen, Oct 26 2014