Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Created August 4, 2014 14:19
Show Gist options
  • Save fmasanori/f364c6baf2c7bea1c96e to your computer and use it in GitHub Desktop.
Save fmasanori/f364c6baf2c7bea1c96e to your computer and use it in GitHub Desktop.
Decimal para binário em Python 3
def dec2bin(n):
b = ''
while n != 0:
b = b + str(n % 2)
n = int(n / 2)
return b[::-1]
def d2b(n):
if n == 0:
return ''
else:
return d2b(n//2) + str(n%2)
@vilaballack
Copy link

Sensacional!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment