Converting 9 is easy, because you only have to deal with one digit. A look up table does the trick.
A more instructive example is converting a number like 909. In this case you must first convert the 900, then deal with the remainder. So 909 is CM followed by the converted form of 9.