Skip to content

Instantly share code, notes, and snippets.

@renskiy
Last active May 5, 2016 16:20
Show Gist options
  • Select an option

  • Save renskiy/1e8e92a9e762f2849813c4f9db22bf70 to your computer and use it in GitHub Desktop.

Select an option

Save renskiy/1e8e92a9e762f2849813c4f9db22bf70 to your computer and use it in GitHub Desktop.
Converts decimal number to the provided base
def convert(number, base):
result = ''
while base < number:
number, remainder = divmod(number, base)
result = str(remainder) + result
return str(number) + result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment