cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A248479 a(1) = 1, a(2) = 3, and from then on alternatively subtract and multiply two previous terms.

This page as a plain text file.
%I A248479 #40 Nov 11 2024 20:31:36
%S A248479 1,3,2,6,4,24,20,480,460,220800,220340,48651072000,48650851660,
%T A248479 2366916086971979520000,2366916086923328668340,
%U A248479 5602291762651594835806920193095352396800000,5602291762651594835804553277008429068131660,31385672993873913406017018916292673201543291913142263413575757282059524278962688000000
%N A248479 a(1) = 1, a(2) = 3, and from then on alternatively subtract and multiply two previous terms.
%H A248479 Reinhard Zumkeller, <a href="/A248479/b248479.txt">Table of n, a(n) for n = 1..25</a>
%F A248479 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.
%F A248479 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
%p A248479 a:= proc(n) option remember;
%p A248479 piecewise(n::odd, a(n-1)-a(n-2), a(n-1)*a(n-2))
%p A248479 end proc:
%p A248479 a(1):= 1: a(2):= 3:
%p A248479 seq(a(n),n=1..20); # _Robert Israel_, Oct 27 2014
%t A248479 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 *)
%o A248479 (Scheme)
%o A248479 (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))))))
%o A248479 ;; A memoizing definec-macro can be found from http://oeis.org/wiki/Memoization - _Antti Karttunen_, Oct 26 2014
%o A248479 (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
%o A248479 (Haskell)
%o A248479 a248479 n = a248479_list !! (n-1)
%o A248479 a248479_list = 1 : 3 : zipWith ($) (map uncurry $ cycle [(-), (*)])
%o A248479                                    (zip (tail a248479_list) a248479_list)
%o A248479 -- _Reinhard Zumkeller_, Oct 28 2014
%Y A248479 Cf. A039941, A077753.
%K A248479 nonn,easy
%O A248479 1,2
%A A248479 _Stuart E Anderson_, Oct 07 2014
%E A248479 One term corrected and additional terms added by _Colin Barker_, Oct 07 2014
%E A248479 Term a(18) added by _Antti Karttunen_, Oct 26 2014