Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- szam = ARGV[0].to_i
- #szam = 991
- roman = ""
- table = [
- ["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']
- ]
- table.length.times { |index|
- arab = table[index][0]
- romai = table[index][1]
- while arab.to_i <= szam
- roman += romai
- szam = szam - arab.to_i
- end
- }
- puts roman
Add Comment
Please, Sign In to add comment