from stack import Stack

def change_base(n, new_base):
		"""Convert the base 10 (non-negative) integer n to base new_base."""
		if n == 0:
				# Easy to handle special case.
		    return "0"
		else:
				stack = Stack()
				digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
				# Repeatedly divide by new_base and push remainders on the stack.
				while n > 0:
						stack.push(n % new_base)
						n /= new_base
				ret = ""
				while not stack.empty():
						ret = ret + digits[stack.pop()]
				return ret
				
				
if __name__ == "__main__":

    print change_base(42, 2) # 101010
    print change_base(10, 16) # A
    print change_base(0, 10)  # 0
    # Why do computer scientists give gifts on Halloween?
    print change_base(25, 8)

