|
|
1.1 root 1: #
2: # R O M A N N U M E R A L S
3: #
4:
5: # This program takes Arabic numerals from standard input and writes
6: # the corresponding Roman numerals to standard outout.
7:
8: procedure main()
9: local n
10: while n := read() do
11: write(roman(n) | "cannot convert")
12: end
13:
14: procedure roman(n)
15: local arabic, result
16: static equiv
17: initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
18: integer(n) > 0 | fail
19: result := ""
20: every arabic := !n do
21: result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
22: if find("*",result) then fail else return result
23: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.