Re: Roman Numerals
- To: mathgroup at smc.vnet.net
- Subject: [mg73717] Re: Roman Numerals
- From: "janos" <janostothmeister at gmail.com>
- Date: Sun, 25 Feb 2007 04:40:40 -0500 (EST)
- References: <erjo00$nmc$1@smc.vnet.net><ermep7$inb$1@smc.vnet.net>
On Feb 23, 11:13 am, "dimitris" <dimmec... at yahoo.com> wrote: > Dear Ajit > > I think you will see many interesting things downloading the package > and the notebook > AntiqueNotations of Robby Villegas from here > > http://library.wolfram.com/infocenter/Demos/4952/ > > Regards > Dimitris > > =CF/=C7 Mr Ajit Sen =DD=E3=F1=E1=F8=E5: > > > Dear Mathgroup, > > > Does Mathematica have any function to convert Arabic > > numerals to Roman, & vice versa? I'm thinking of > > something like > > > Roman[2007] ---> MMVII > > > Arabic[MDCCLXIV] ---> 1764 > > > I just thought about that after seeing the date in > > the credits of an old movie, & I reckoned it'd > > be faster to use Mathematica than use a convertor on the Web. > > > I could not get any info from the Help browser or the archive. > > A Yes/No answer with a few words will do. I don't > > really need a code. Unless someone has plenty of spare > > time. > > > Thanks. > > Ajit Sen. > > > ___________________________________________________________ > > Now you can scan emails quickly with a reading pane. Get the new Yahoo! M > > ail.http://uk.docs.yahoo.com/nowyoucan.html Dear Ajit, I also liked the proposed nb, but you might be still be interested in reading this small recursive program calculating Roman numerals (form our book with L. Szili, 1996). arabic = Union[10^Range[0, 3], Flatten[Outer[Times, {9, 5,4}, 10^Range[0, 2]]], {0}]; roman = ToString /@ {{}, I, IV,V, IX, X, XL, L, XC, C, CD, D, CM, M}; MapThread[SetDelayed, {ToRoman /@ arabic, roman}]; cap[x_Integer /; 0 < x < 4000] := First[Select[Reverse[arabic], # < x &, 1]]; ToRoman[x_Integer /; 0 < x < 4000] := SequenceForm[ToRoman[cap[x]], ToRoman[x - cap[x]]] ToRoman /@ (2^Range[0, 12])