Skip to content

Instantly share code, notes, and snippets.

@VxDxK
Last active March 2, 2021 18:29
Show Gist options
  • Save VxDxK/afef79e6a77c5bb6449070f847f6f6fc to your computer and use it in GitHub Desktop.
Save VxDxK/afef79e6a77c5bb6449070f847f6f6fc to your computer and use it in GitHub Desktop.
def toBase(base, num):
newNum = ''
while num > 0:
newNum = str(num % base) + newNum
num //= base
return newNum
def toDec(num, base):
iu = str(num)
s = 0
t = 0
yr = 0
for i in range(len(iu) - 1, -1, -1):
s += int(iu[i]) * (base ** yr)
yr += 1
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment