Created
May 26, 2015 02:46
-
-
Save data-doge/bbda87b588a06b539d3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $cipher = {1000 => "M", 900 => "CM", 500 => "D", 400 => "CD", 100 => "C", 90 => "XC", 50 => "L", 40 => "XL", 10 => "X", 9 => "IX", 5 => "V", 4 => "IV", 1 => "I"} | |
| def to_roman(number) | |
| roman_numeral = "" | |
| $cipher.each do |arabic, roman| | |
| count = number / arabic | |
| roman_numeral += roman * count | |
| number -= arabic * count | |
| end | |
| roman_numeral | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment