Created
January 15, 2015 21:56
-
-
Save sixthgear/c4c490e1d74f23146fcf to your computer and use it in GitHub Desktop.
Revisions
-
sixthgear created this gist
Jan 15, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ main = getLine >>= \d -> putStrLn (decToRoman (read d :: Integer)) >> main decToRoman :: Integer -> String decToRoman dec | dec >= 1000 = "M" ++ decToRoman(dec - 1000) | dec >= 900 = "CM" ++ decToRoman(dec - 900) | dec >= 500 = "D" ++ decToRoman(dec - 500) | dec >= 400 = "CD" ++ decToRoman(dec - 400) | dec >= 100 = "C" ++ decToRoman(dec - 100) | dec >= 90 = "XC" ++ decToRoman(dec - 90) | dec >= 50 = "L" ++ decToRoman(dec - 50) | dec >= 40 = "XL" ++ decToRoman(dec - 40) | dec >= 10 = "X" ++ decToRoman(dec - 10) | dec >= 9 = "IX" ++ decToRoman(dec - 9) | dec >= 5 = "V" ++ decToRoman(dec - 5) | dec >= 4 = "IV" ++ decToRoman(dec - 4) | dec >= 1 = "I" ++ decToRoman(dec - 1) | otherwise = ""