Last active
June 2, 2016 23:49
-
-
Save brettfreer/7ef9e41b44cee51a35bace8ce97d8cec to your computer and use it in GitHub Desktop.
Convert integer to another base, returning a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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