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-2 of 2 results.

A266569 a(1) = 1; thereafter a(2k) = 4k + a(k); a(2k+1) = k + a(4k+4).

Original entry on oeis.org

1, 5, 30, 13, 68, 42, 64, 29, 132, 88, 119, 66, 154, 92, 132, 61, 248, 168, 217, 128, 261, 163, 221, 114, 322, 206, 273, 148, 326, 192, 268, 125, 468, 316, 401, 240, 463, 293, 387, 208, 533, 345, 448, 251, 519, 313, 425, 210, 646, 422, 543, 310, 623, 381, 511
Offset: 1

Views

Author

Daniel Suteu, Jan 01 2016

Keywords

Examples

			For n=2, a(2) = 4 + a(1) = 5.
For n=3:
a(3) = 1 + a(8);
a(8) = 2*8 + a(8/2) = 16 + a(4);
a(4) = 2*4 + a(4/2) = 8 + a(2) = 13;
a(8) = 18+13 = 29;
a(3) = 1 + 29 = 30.
		

Crossrefs

Records (high water marks): A270811, A270812.

Programs

  • Maple
    A266569 := proc(n)
        option remember;
        local k;
        if n = 1 then
            1;
        elif type(n,'even') then
            2*n+procname(n/2) ;
        else
            k := (n-1)/2 ;
            k+procname(4*k+4) ;
        end if;
    end proc:
    seq(A266569(n),n=1..100) ; # R. J. Mathar, May 06 2016
  • Mathematica
    a[1] = 1; a[n_] := a[n] = If[EvenQ@ n, 2 n + a[n/2], (n - 1)/2 + a[2 (n + 1)]]; Array[a, 55] (* Michael De Vlieger, Jan 02 2016 *)
  • Sidef
    func a((1)) { 1 }
    func a(n {.is_even}) is cached { 2*n + a(n/2) }
    func a(n {.is_odd }) is cached { (n-1)/2 + a(2*(n + 1)) }
    1000.times { |n| say a(n) }

A271478 If n is even, a(n)=n/2, otherwise 2*n+2.

Original entry on oeis.org

0, 4, 1, 8, 2, 12, 3, 16, 4, 20, 5, 24, 6, 28, 7, 32, 8, 36, 9, 40, 10, 44, 11, 48, 12, 52, 13, 56, 14, 60, 15, 64, 16, 68, 17, 72, 18, 76, 19, 80, 20, 84, 21, 88, 22, 92, 23, 96, 24, 100, 25, 104, 26, 108, 27, 112, 28, 116, 29, 120, 30, 124, 31, 128, 32, 132, 33, 136, 34, 140, 35
Offset: 0

Views

Author

N. J. A. Sloane, Apr 10 2016

Keywords

Comments

Arises in studying A266569.

Crossrefs

Programs

  • Maple
    f:=n->if n mod 2 = 0 then n/2 else 2*n+2; fi;
    [seq(f(n),n=0..100)];
  • Mathematica
    Table[(5 n - (-1)^n (3 n + 4) + 4)/4, {n, 0, 70}] (* Ilya Gutkovskiy, Apr 11 2016 *)
  • PARI
    concat(0, Vec(x*(4+x)/((1-x)^2*(1+x)^2) + O(x^50))) \\ Colin Barker, Apr 11 2016
    
  • PARI
    a(n) = if (n % 2, 2*n+2, n/2); \\ Michel Marcus, Apr 11 2016
    
  • Python
    for n in range(0,10**3):
        if(not n%2):print((int)(n/2))
        else:print(2*n+2)
    # Soumil Mandal, Apr 11 2016

Formula

From Colin Barker, Apr 11 2016: (Start)
a(n) = 2*a(n-2)-a(n-4) for n>3.
G.f.: x*(4+x) / ((1-x)^2*(1+x)^2). (End)
a(n) = (5*n - (-1)^n*(3*n + 4) + 4)/4. - Ilya Gutkovskiy, Apr 11 2016
Showing 1-2 of 2 results.