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.

Showing 1-3 of 3 results.

A039941 Alternately add and multiply.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 4, 8, 12, 96, 108, 10368, 10476, 108615168, 108625644, 11798392572168192, 11798392680793836, 139202068568601556987554268864512, 139202068568601568785946949658348, 19377215893777651167043206536157390321290709180447278572301746176
Offset: 0

Views

Author

Keywords

Crossrefs

A001696(n)=A039941(2*n), A001697(n)=A039941(2*n+1).

Programs

  • Haskell
    a039941 n = a039941_list !! (n-1)
    a039941_list = 0 : 1 : zipWith3 ($)
       (cycle [(+),(*)]) a039941_list (tail a039941_list)
    -- Reinhard Zumkeller, May 07 2012
  • Mathematica
    nxt[{n_,a_,b_}]:={n+1,b,If[EvenQ[n],a+b,a*b]}; Join[{0},Transpose[ NestList[ nxt,{0,0,1},20]][[3]]] (* Harvey P. Dale, Aug 23 2013 *)
  • PARI
    a(n)=if(n<2,n>0, if(n%2,a(n-1)*a(n-2),a(n-1)+a(n-2)))
    

Formula

a(2n) = a(2n-1) + a(2n-2); a(2n+1) = a(2n-1)*a(2n); a(0) = 0; a(1) = 1
a(n) = {a(n-1) + a(n-2), n even, a(n-1)*a(n-2), n odd}; a(0)=0; a(1)=1.

Extensions

Additional comments from Michael Somos, May 19 2000
One more term from Harvey P. Dale, Aug 23 2013

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

Original entry on oeis.org

1, 3, 2, 6, 4, 24, 20, 480, 460, 220800, 220340, 48651072000, 48650851660, 2366916086971979520000, 2366916086923328668340, 5602291762651594835806920193095352396800000, 5602291762651594835804553277008429068131660, 31385672993873913406017018916292673201543291913142263413575757282059524278962688000000
Offset: 1

Views

Author

Stuart E Anderson, Oct 07 2014

Keywords

Crossrefs

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

A320603 a(0) = 1; if n is odd, a(n) = Product_{i=0..n-1} a(i); if n is even, a(n) = Sum_{i=0..n-1} a(i).

Original entry on oeis.org

1, 1, 2, 2, 6, 24, 36, 20736, 20808, 8947059130368, 8947059171984, 716210897494804754044764041567551881216, 716210897494804754044764059461670225184
Offset: 0

Views

Author

Iain Fox, Oct 17 2018

Keywords

Comments

Next term is too large to include.
Odd terms are the product of previous terms and even terms are the sum of previous terms.

Examples

			5 is odd, so a(5) = 1 * 1 * 2 * 2 * 6 = 24.
6 is even, so a(6) = 1 + 1 + 2 + 2 + 6 + 24 = 36.
		

Crossrefs

Sum of previous terms: A011782.
Product of previous terms: A165420.

Programs

  • Mathematica
    a[0]:= 1; a[n_]:= If[OddQ[n], Product[a[j], {j,0,n-1}], Sum[a[j], {j,0,n -1}]]; Table[a[n], {n, 0, 15}] (* G. C. Greubel, Oct 19 2018 *)
  • PARI
    first(n) = my(res = vector(n, i, 1)); for(x=3, n, res[x]=if(x%2, sum(i=1, x-1, res[i]), prod(i=1, x-1, res[i]))); res
    
  • PARI
    first(n) = my(res = vector(n, i, 1)); res[3]++; for(x=4, n, res[x]=if(x%2, res[x-1]+2*res[x-2], res[x-1]*res[x-2]^2)); res

Formula

a(n) = a(n-1) + 2*a(n-2), for even n > 2.
a(n) = a(n-1) * a(n-2)^2, for odd n > 1.
Showing 1-3 of 3 results.