Search code examples
javac++pythonalgorithmroman-numerals

Roman representation of integers


Possible Duplicate:
How do you find a roman numeral equivalent of an integer

I am looking for a simple algorithm (preferably in Python). How to translate a given integer number to a Roman number?

string Roman(int Num){...}

For example, Roman(1981) must produce "MCMLXXXI".


Solution

  • I needed the opposite one time (going from Roman numerals to int). Wikipedia has surprisingly detailed information on how Roman numerals work. Once you realize that things are this well-defined and that a specification is available this easily, translating it to code is fairly trivial.