704 Factors of Two in Binomial Coefficients.gp 319 B

1234567891011121314151617
  1. \\ Pari/GP
  2. \\ Daniel "Trizen" Șuteu
  3. \\ Date: 03 March 2020
  4. \\ https://github.com/trizen
  5. \\ Factors of Two in Binomial Coefficients
  6. \\ https://projecteuler.net/problem=704
  7. \\ Runtime: 0.165s
  8. A(n) = (n+1) * logint(n, 2) - 2*(2^logint(n,2) - 1);
  9. B(n) = n - hammingweight(n);
  10. S(n) = A(n+1) - B(n+1);
  11. print(S(10^16));