June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
17
Task/Roman-numerals-Encode/SETL/roman-numerals-encode.setl
Normal file
17
Task/Roman-numerals-Encode/SETL/roman-numerals-encode.setl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
examples := [2008, 1666, 1990];
|
||||
|
||||
for example in examples loop
|
||||
print( roman_numeral(example) );
|
||||
end loop;
|
||||
|
||||
proc roman_numeral( n );
|
||||
R := [[1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'], [100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'], [10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I']];
|
||||
roman := '';
|
||||
for numeral in R loop
|
||||
while n >= numeral(1) loop
|
||||
n := n - numeral(1);
|
||||
roman := roman + numeral(2);
|
||||
end loop;
|
||||
end loop;
|
||||
return roman;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue