login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A248479
a(1) = 1, a(2) = 3, and from then on alternatively subtract and multiply two previous terms.
3
1, 3, 2, 6, 4, 24, 20, 480, 460, 220800, 220340, 48651072000, 48650851660, 2366916086971979520000, 2366916086923328668340, 5602291762651594835806920193095352396800000, 5602291762651594835804553277008429068131660, 31385672993873913406017018916292673201543291913142263413575757282059524278962688000000
OFFSET
1,2
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..25
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
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 *)
PROG
(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
(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
(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
CROSSREFS
Sequence in context: A348404 A218615 A177828 * A304533 A090571 A088452
KEYWORD
nonn,easy
AUTHOR
Stuart E Anderson, Oct 07 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
STATUS
approved