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.

A061168 Partial sums of floor(log_2(k)) (= A000523(k)).

Original entry on oeis.org

0, 1, 2, 4, 6, 8, 10, 13, 16, 19, 22, 25, 28, 31, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 103, 108, 113, 118, 123, 128, 133, 138, 143, 148, 153, 158, 163, 168, 173, 178, 183, 188, 193, 198, 203, 208, 213, 218, 223, 228, 233, 238, 243, 248
Offset: 1

Views

Author

Antti Karttunen, Apr 19 2001

Keywords

Comments

Given a term b>0 of the sequence and its left hand neighbor c, the corresponding unique sequence index n with property a(n)=b can be determined by n(b)=e+(b-d*(e+1)+2*(e-1))/d, where d=b-c and e=2^d. - Hieronymus Fischer, Dec 05 2006
a(n) gives index of start of binary expansion of n in the binary Champernowne sequence A076478. - N. J. A. Sloane, Dec 14 2017
a(n) is the number of pairs in ancestor relationship (= transitive closure of the parent relationship) in all (binary) heaps on n elements. - Alois P. Heinz, Feb 13 2019

References

  • D. E. Knuth, Fundamental Algorithms, Addison-Wesley, 1973, Section 1.2.4, ex. 42(b).

Crossrefs

Programs

  • Haskell
    import Data.List (transpose)
    a061168 n = a061168_list !! n
    a061168_list = zipWith (+) [0..] (zipWith (+) hs $ tail hs) where
       hs = concat $ transpose [a001855_list, a001855_list]
    -- Reinhard Zumkeller, Jun 03 2013
    
  • Maple
    seq(add(floor(log[2](k)),k=1..j),j=1..100);
    # second Maple program:
    a:= proc(n) option remember; `if`(n<1, 0, ilog2(n)+a(n-1)) end:
    seq(a(n), n=1..80);   # Alois P. Heinz, Feb 12 2019
  • Mathematica
    Accumulate[Floor[Log[2,Range[110]]]] (* Harvey P. Dale, Jul 16 2012 *)
    a[n_] := (n+1) IntegerLength[n+1, 2] - 2^IntegerLength[n+1, 2] - n + 1;
    Table[a[n], {n, 1, 61}] (* Peter Luschny, Dec 02 2017 *)
  • PARI
    a(n)=if(n<1,0,if(n%2==0,a(n/2)+a(n/2-1)+n-1,2*a((n-1)/2)+n-1)) /* _Ralf Stephan */
    
  • PARI
    a(n)=local(k); if(n<1,0,k=length(binary(n))-1; (n+1)*k-2*(2^k-1))
    
  • PARI
    { for (n=1, 1000, k=length(binary(n))-1; write("b061168.txt", n, " ", (n + 1)*k - 2*(2^k - 1)) ) } \\ Harry J. Smith, Jul 18 2009
    
  • Python
    def A061168(n):
        s, i, z = -n , n, 1
        while 0 <= i: s += i; i -= z; z += z
        return s
    print([A061168(n) for n in range(1, 62)]) # Peter Luschny, Nov 30 2017
    
  • Python
    def A061168(n): return (n+1)*((m:=n.bit_length())-1)-(1<Chai Wah Wu, Mar 29 2023

Formula

a(n) = A001855(n+1) - n.
a(n) = Sum_{k=1..n} floor(log_2(k)) = (n+1)*floor(log_2(n)) - 2*(2^floor(log_2(n)) - 1). - Diego Torres (torresvillarroel(AT)hotmail.com), Oct 29 2002
G.f.: 1/(1-x)^2 * Sum(k>=1, x^2^k). - Ralf Stephan, Apr 13 2002
a(n) = A123753(n) - 2*n - 1. - Peter Luschny, Nov 30 2017