Post Reply 
Roman Numeral Function
01-21-2016, 01:42 PM
Post: #10
RE: Roman Numeral Function
Hi!

Here there is a slightly modified version of Didiers's A→R, that also give good results for N between 1 and 3999

Code:
EXPORT A→R(N)
BEGIN
  LOCAL r:={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
  LOCAL d:={1000,900,500,400,100,90,50,40,10,9,5,4,1};
  LOCAL j,s:="";

  FOR j FROM 1 TO 13 DO
    WHILE N≥d(j) DO s:=s+r(j); N:=N-d(j); END;
  END;
  RETURN s;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Roman Numeral Function - smp - 01-17-2016, 09:29 PM
RE: Roman Numeral Function - John Colvin - 01-19-2016, 09:46 PM
RE: Roman Numeral Function - smp - 01-19-2016, 10:12 PM
RE: Roman Numeral Function - Gerald H - 01-20-2016, 05:56 AM
RE: Roman Numeral Function - Gerald H - 01-20-2016, 04:09 PM
RE: Roman Numeral Function - Gerald H - 01-21-2016, 10:45 AM
RE: Roman Numeral Function - DrD - 01-21-2016, 11:49 AM
RE: Roman Numeral Function - JMB - 01-21-2016 01:42 PM



User(s) browsing this thread: 1 Guest(s)