Created
July 21, 2021 13:36
-
-
Save igorvanloo/452ed472b04594ed3bd61e0a8d34aaae to your computer and use it in GitHub Desktop.
Base Changing Function
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): | |
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