• + 2 comments

    No closed form equation is known, as discussed in A061418.

    For fun, here's a bitwise solution:

    m = 2
    tot = 2
    for _ in range(1, input()):
        m += m>>1
        tot += m
    print tot
    

    Here's how it works:

    1. floor(3x / 2)
    2. floor(2x/2 + x/2)
    3. floor(x + x/2)
    4. x + floor(x/2) --->{since x is int, see here}
    5. x + x>>1 -------->{bitwise shift right x by k = floor(x/2^k}

    Method taken from here