Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created July 21, 2021 13:36
Show Gist options
  • Save igorvanloo/452ed472b04594ed3bd61e0a8d34aaae to your computer and use it in GitHub Desktop.
Save igorvanloo/452ed472b04594ed3bd61e0a8d34aaae to your computer and use it in GitHub Desktop.
Base Changing Function
def numberToBase(n, b):
if n == 0:
return [0]
digits = []
while n != 0:
digits.append(int(n % b))
n //= b
return digits[::-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment