def f(n, c): while True: n, r = divmod(n, c) print n, r if not n: return