OFFSET
0,5
LINKS
Antoine Mathys, Table of n, a(n) for n = 0..9999
Project Euler, Problem 704 - Factors of Two in Binomial Coefficients.
FORMULA
MAPLE
a:= proc(n) option remember; `if`(n<0, 0,
a(n-1)+ilog2(n+1)-padic[ordp](n+1, 2))
end:
seq(a(n), n=0..60); # Alois P. Heinz, Jun 23 2024
MATHEMATICA
Accumulate[Table[BitLength[k] - 1 - IntegerExponent[k, 2], {k, 100}]] (* Paolo Xausa, Oct 01 2024 *)
PROG
(PARI)
bit_width(n)=logint(n, 2)+1;
a(n)=my(d=bit_width(n+1), p=hammingweight(n+1)); (n+2)*d-2*n-2^d+p-1;
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Antoine Mathys, Jun 14 2024
STATUS
approved