A295513 a(n) = n*bil(n) - 2^bil(n) where bil(0) = 0 and bil(n) = floor(log_2(n)) + 1 for n>0.
-1, -1, 0, 2, 4, 7, 10, 13, 16, 20, 24, 28, 32, 36, 40, 44, 48, 53, 58, 63, 68, 73, 78, 83, 88, 93, 98, 103, 108, 113, 118, 123, 128, 134, 140, 146, 152, 158, 164, 170, 176, 182, 188, 194, 200, 206, 212, 218, 224, 230, 236, 242, 248, 254, 260, 266, 272, 278
Offset: 0
Keywords
Links
- Hsien-Kuei Hwang, S. Janson, and T.-H. Tsai, Exact and asymptotic solutions of the recurrence f(n) = f(floor(n/2)) + f(ceiling(n/2)) + g(n): theory and applications, Preprint 2016.
Programs
-
Maple
A295513 := proc(n) local i, s, z; s := -1; i := n-1; z := 1; while 0 <= i do s := s+i; i := i-z; z := z+z od; s end: seq(A295513(n), n=0..57);
-
Mathematica
a[n_] := n IntegerLength[n, 2] - 2^IntegerLength[n, 2]; Table[a[n], {n, 0, 58}]
-
Python
def A295513(n): return n*(m:=(n-1).bit_length())-(1<
Chai Wah Wu, Mar 29 2023