Skip to content

Instantly share code, notes, and snippets.

@TranNgocMinh
Last active February 6, 2018 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TranNgocMinh/23dfcffe4f06ca67168a56fc6cd4e256 to your computer and use it in GitHub Desktop.
Save TranNgocMinh/23dfcffe4f06ca67168a56fc6cd4e256 to your computer and use it in GitHub Desktop.
def binary(number):
base = 1
binary_val = 0
while(number > 0):
rem = number%2
binary_val = binary_val + rem*base
number = number/2
base = base*10
return binary_val
number = long(raw_input("Nhap so he thap phan:"))
print "Dang nhi phan la:",binary(number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment