Skip to main content
deleted 10 characters in body
Source Link
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13

Mathematica

Mathematica has its built-in function DigitCount function is as fast as expected.

Try it online!

popCount[n_Integer] := DigitCount[n, 2, 1];
(ans=popCount[115792089237316195423570985008687907853269984665640564039457584007913129639935])//AbsoluteTiming//Print

Mathematica

Mathematica DigitCount function is as fast as expected.

Try it online!

popCount[n_Integer] := DigitCount[n, 2, 1];
(ans=popCount[115792089237316195423570985008687907853269984665640564039457584007913129639935])//AbsoluteTiming//Print

Mathematica

Mathematica has its built-in function DigitCount.

Try it online!

popCount[n_Integer] := DigitCount[n, 2, 1];
(ans=popCount[115792089237316195423570985008687907853269984665640564039457584007913129639935])//AbsoluteTiming//Print
Source Link
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13

Mathematica

Mathematica DigitCount function is as fast as expected.

Try it online!

popCount[n_Integer] := DigitCount[n, 2, 1];
(ans=popCount[115792089237316195423570985008687907853269984665640564039457584007913129639935])//AbsoluteTiming//Print