06-14-2014, 08:59 AM
Small program that converts a integer to Roman number, inspired from a thread in the General Forum
Code:
EXPORT Roman()
BEGIN
LOCAL R:="";
L1:={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
L2:={1000,900,500,400,100,90,50,40,10,9,5,4,1};
PRINT();
INPUT(L,"Roman numbers","Integer");
A:=L; //Remember input
FOR I FROM 1 TO SIZE(L2) DO
T:=IP(L/L2(I));
L:=L-T*L2(I);
FOR J FROM 1 TO T DO
R:=R + L1(I);
END;
END;
PRINT(A+" = " + R);
END;