Skip to main content
2 of 2
Commonmark migration

Matlab, 13 bytes

de2bi creates a vector of zeros and ones representing the binary number, and sum just returns the sum of all the entries.

sum(de2bi(n))
flawr
  • 43.9k
  • 7
  • 104
  • 249