Created
January 15, 2017 22:35
-
-
Save Danielapariona/6de8dbc979d9a2e7eb00a057243d75a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
n = 23 | |
nro_uno = 0 | |
b = n.to_s(2) | |
for i in 0..b.length-1 | |
if b[i] == "1" | |
nro_uno += 1 | |
end | |
end | |
puts nro_uno |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment