RosettaCodeData/Task/Roman-numerals-Encode/Phix/roman-numerals-encode.phix

14 lines
386 B
Plaintext

constant roman = {"M", "CM", "D","CD", "C","XC","L","XL","X","IX","V","IV","I"}
constant decml = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }
function toRoman(integer val)
string res = ""
for i=1 to length(roman) do
while val>=decml[i] do
res &= roman[i]
val -= decml[i]
end while
end for
return res
end function