Skip to content

Instantly share code, notes, and snippets.

@hughdbrown
Created November 2, 2017 04:59
Show Gist options
  • Save hughdbrown/5563f99fc78b8cd2a6a6c7721009c9de to your computer and use it in GitHub Desktop.
Save hughdbrown/5563f99fc78b8cd2a6a6c7721009c9de to your computer and use it in GitHub Desktop.
Calculate the values for a base encoding
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