Skip to main content
1 of 2
alephalpha
  • 50k
  • 7
  • 68
  • 182

#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