Examples Delphi

This article demonstrates how to convert a given number to Roman Numerals in Delphi.
function DecToRoman ( iDecimal: longint ): string;
const
aRomans: array [ 1..13 ] of string = ( 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M' );
aArabics: array [ 1..13 ] of integer = ( 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 );
var
i: integer;
begin
result := '';
for i := 13 downto 1 do
while ( iDecimal >= aArabics [ i ] ) do begin
iDecimal := iDecimal - aArabics [ i ];
result := result + aRomans [ i ];
end;
end;