Skip to content

Instantly share code, notes, and snippets.

@Danielapariona
Created January 15, 2017 22:35
Show Gist options
  • Save Danielapariona/6de8dbc979d9a2e7eb00a057243d75a5 to your computer and use it in GitHub Desktop.
Save Danielapariona/6de8dbc979d9a2e7eb00a057243d75a5 to your computer and use it in GitHub Desktop.
#!/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