let's take a number a in base 10:

if is a base ten expansion of a, then we may right a like so:

Now if we want to express a in terms of a base b expansion. we express a in terms of powers of b. This can be done by either brute force or modular exponentiation.

then we get