Created
January 5, 2014 17:02
-
-
Save anonymous/8270782 to your computer and use it in GitHub Desktop.
This file contains 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
text = '' | |
def call_numerals num | |
array_num = [1000, 500, 100, 50, 10, 5, 1] | |
array_letter = ['M', 'D', 'C', 'L', 'X', 'V', 'I'] | |
roman_numerals num, array_num, array_letter | |
end | |
def roman_numerals num, array_num, array_letter | |
letter_number = 0 | |
array_num.each do |n| | |
left = num % n | |
text << array_letter[letter_number] * left | |
letter_number.+1 | |
end | |
text | |
end | |
puts(call_numerals(125)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment