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.

A077138 a(0) = 0. If n is odd, a(n) = a(n-1) + n, otherwise a(n) = a(n-1) * n.

Original entry on oeis.org

0, 1, 2, 5, 20, 25, 150, 157, 1256, 1265, 12650, 12661, 151932, 151945, 2127230, 2127245, 34035920, 34035937, 612646866, 612646885, 12252937700, 12252937721, 269564629862, 269564629885, 6469551117240, 6469551117265, 168208329048890
Offset: 0

Views

Author

Amarnath Murthy, Oct 30 2002

Keywords

Crossrefs

Programs

  • Mathematica
    a = 0; Table[If[OddQ[n], a = n + a, a = n*a], {n, 0, 30}] (* T. D. Noe, Feb 26 2013 *)
    nxt[{n_,a_}]:={n+1,If[EvenQ[n],a+n+1,a(n+1)]}; NestList[nxt,{0,0},30][[All,2]] (* Harvey P. Dale, Feb 13 2022 *)
  • PARI
    a(n)=if(n<0,0,if(n%2,n+a(n-1),n*a(n-1)))
    
  • Python
    a=0
    for n in range(1, 33):
        print(a, end=', ')
        if n&1:
            a += n
        else:
            a *= n

Formula

a(0) = 0, a(2n) = 2n*a(2n-1) and a(2n+1) = a(2n) +(2n +1).

Extensions

Name improved by T. D. Noe, Feb 26 2013