Created
November 2, 2017 04:59
-
-
Save hughdbrown/5563f99fc78b8cd2a6a6c7721009c9de to your computer and use it in GitHub Desktop.
Calculate the values for a base encoding
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 numberToBase(n, b): | |
def _divmod(n, b): | |
while n: | |
n, q = divmod(n, b) | |
yield q | |
return [0] if not n else list(reversed(list(_divmod(n, b)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment