Last active
May 5, 2016 16:20
-
-
Save renskiy/1e8e92a9e762f2849813c4f9db22bf70 to your computer and use it in GitHub Desktop.
Converts decimal number to the provided base
This file contains hidden or 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
| 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