
# base.py


def toBase(n, base):
  # convert n to the specified base
  bp = base
  exp = 1
  while n >= bp:
    bp *= base
    exp += 1

  rep = []
  for  i in range(exp):
    bp =  bp // base
    rep.append(n // bp)
    n %= bp
  return rep


# ---------------------------------

print("10 base 2 =", toBase(10, 2))
print("89 base 3 =", toBase(89, 3))
