Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Roman-numerals-Encode/Io/roman-numerals-encode.io
Normal file
18
Task/Roman-numerals-Encode/Io/roman-numerals-encode.io
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Roman := Object clone do (
|
||||
nums := list(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
|
||||
rum := list("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I")
|
||||
|
||||
numeral := method(number,
|
||||
result := ""
|
||||
for(i, 0, nums size,
|
||||
if(number == 0, break)
|
||||
while(number >= nums at(i),
|
||||
number = number - nums at(i)
|
||||
result = result .. rum at(i)
|
||||
)
|
||||
)
|
||||
return result
|
||||
)
|
||||
)
|
||||
|
||||
Roman numeral(1666) println
|
||||
Loading…
Add table
Add a link
Reference in a new issue