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

A200310 a(n) = n-1 for n <= 4, otherwise if n is even then a(n) = a(n-5)+2^(n/2), and if n is odd then a(n) = a(n-1)+2^((n-3)/2).

Original entry on oeis.org

0, 1, 2, 3, 5, 8, 12, 18, 26, 37, 53, 76, 108, 154, 218, 309, 437, 620, 876, 1242, 1754, 2485, 3509, 4972, 7020, 9946, 14042, 19893, 28085, 39788, 56172, 79578, 112346, 159157, 224693, 318316, 449388, 636634, 898778, 1273269, 1797557, 2546540, 3595116, 5093082, 7190234, 10186165, 14380469
Offset: 1

Views

Author

N. J. A. Sloane, Nov 15 2011

Keywords

Comments

This sequence encodes the solution to the problem of finding the number of comparisons needed for optimal merging of 2 elements with n elements. See also A200311, A239100.

Crossrefs

Programs

  • Magma
    [Floor((29+5*(-1)^n)*2^((2*n-7-(-1)^n)/4)/7)-1 : n in [1..50]]; // Wesley Ivan Hurt, Mar 24 2015
    
  • Magma
    I:=[0,1,2,3,5,8,12]; [n le 7 select I[n] else Self(n-1)+Self(n-2)-Self(n-3)+Self(n-4)-Self(n-5)+2*Self(n-6)-2*Self(n-7): n in [1..50]]; // Vincenzo Librandi, Mar 25 2015
  • Maple
    A200310 := proc(n)
        option remember;
        if n =0 then
            0 ;
        elif n <= 4 then
            n-1
        else
            if n mod 2 = 0 then
                procname(n-5)+2^(n/2)
            else
                procname(n-1)+2^((n-3)/ 2);
            fi;
        fi;
    end proc:
    seq(A200310(n),n=1..40) ;
  • Mathematica
    Table[Floor[(29 + 5 (-1)^n)*2^((2n - 7 - (-1)^n)/4)/7] - 1, {n, 50}] (* Wesley Ivan Hurt, Mar 24 2015 *)
    CoefficientList[Series[x (1 + x + x^3 + x^4 + x^5) / ((x - 1)(2 x^2 - 1) (1 + x + x^2) (x^2 - x + 1)), {x, 0, 50}], x] (* Vincenzo Librandi, Mar 25 2015 *)

Formula

If n mod 2 = 0 then set k:=n/2 and a(n) = floor(17*2^(k-1)/7) - 1; otherwise set k:=(n+1)/2 and a(n) = floor(12*2^(k-1)/7) - 1.
G.f.: x^2*(1+x+x^3+x^4+x^5) / ( (x-1)*(2*x^2-1)*(1+x+x^2)*(x^2-x+1) ). - R. J. Mathar, Nov 15 2011
From Wesley Ivan Hurt, Mar 24 2015: (Start)
a(n) = a(n-1)+a(n-2)-a(n-3)+a(n-4)-a(n-5)+2*a(n-6)-2*a(n-7).
a(n) = floor((29+5(-1)^n)*2^((2n-7-(-1)^n)/4)/7)-1. (End)
Showing 1-1 of 1 results.