Skip to main content
2 of 2
Commonmark migration

Octave, 18

sum(dec2bin(s)-48)

Example:

octave:1> s=1337
s =  1337
octave:2> sum(dec2bin(s)-48)
ans =  6
alephalpha
  • 50k
  • 7
  • 68
  • 182