Skip to content

Instantly share code, notes, and snippets.

@brettfreer
Last active June 2, 2016 23:49
Show Gist options
  • Save brettfreer/7ef9e41b44cee51a35bace8ce97d8cec to your computer and use it in GitHub Desktop.
Save brettfreer/7ef9e41b44cee51a35bace8ce97d8cec to your computer and use it in GitHub Desktop.
Convert integer to another base, returning a string
# convert base-10 integer a to base-b, returning a string
def convert(a,b):
add = a % b
if a <= 1:
return str(a)
return str(convert(a//b, b)) + str(add)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment