Problem 63. Encode Roman Numerals
Create a function taking a non-negative integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
By convention, "modern" Roman numerals are written by expressing each digit separately starting with the leftmost digit and skipping any digit with a value of zero.
Examples
- If n is 1990 then romStr = 'MCMXC' since 1000=M, 900=CM, 90=XC.
- If n is 2008 then romStr = 'MMVIII' since 2000=MM, 8=VIII.
- If n is 1666 then romStr = 'MDCLXVI'.
- If n is 0 then romStr is empty ([] and '' are both acceptable)
n will always be an integer between 0 and 3999 (inclusive).
Solution Stats
Problem Comments
-
1 Comment
Cris Luengo
on 15 Jul 2012
It would be good if Cody penalized huge strings. :)
Solution Comments
Show commentsProblem Recent Solvers1935
Suggested Problems
-
2244 Solvers
-
Project Euler: Problem 4, Palindromic numbers
1041 Solvers
-
Back to basics 11 - Max Integer
785 Solvers
-
Numbers with prime factors 2, 3 and 5.
475 Solvers
-
"Low : High - Low : High - Turn around " -- Create a subindices vector
540 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!