DNAnexus Interview Question

Create a function converting a decimal number to a different base. Describe and algorithm.