Skip to content

Instantly share code, notes, and snippets.

@alexandre
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save alexandre/44e6d630d6e4f77d669c to your computer and use it in GitHub Desktop.

Select an option

Save alexandre/44e6d630d6e4f77d669c to your computer and use it in GitHub Desktop.
converter um valor em decimal para binário
conv = []
def dec2bin(num):
(num/2 > 0 and (dec2bin(int(num/2)), conv.append(num%2)))
dec2bin(int(input('Decimal: ')))
print(''.join(map(str, conv)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment