Created
February 19, 2021 06:18
-
-
Save Chemasmas/cec94131fca3bfe1f6f72f850cad2f72 to your computer and use it in GitHub Desktop.
Solucion de Chemasmas
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
object Solution { | |
def intToRoman(num: Int): String = { | |
return if(num >= 1000) | |
"M" + intToRoman(num-1000) | |
else if(num >= 900) | |
"CM" + intToRoman(num-900) | |
else if(num >= 500) | |
"D" + intToRoman(num-500) | |
else if(num >= 400) | |
"CD" + intToRoman(num-400) | |
else if(num >= 100) | |
"C" + intToRoman(num-100) | |
else if(num >= 90) | |
"XC" + intToRoman(num-90) | |
else if(num >= 50) | |
"L" + intToRoman(num-50) | |
else if(num >= 40) | |
"XL" + intToRoman(num-40) | |
else if(num >= 10) | |
"X" + intToRoman(num-10) | |
else if(num >= 9) | |
"IX" + intToRoman(num-9) | |
else if(num >= 5) | |
"V" + intToRoman(num-5) | |
else if(num >= 4) | |
"IV" + intToRoman(num-4) | |
else if(num > 0) | |
"I" + intToRoman(num-1) | |
else | |
"" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment