For Programmers: Free Programming Magazines  


Home > Archive > Mathematica > February 2007 > Roman Numerals









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Roman Numerals
Mr Ajit Sen

2007-02-22, 4:24 am

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! Mail. http://uk.docs.yahoo.com/nowyoucan.html

dimitris

2007-02-23, 4:23 am

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


janos

2007-02-25, 4:16 am

On Feb 23, 11:13 am, "dimitris" <dimmec...@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:
>
>
>
>
>
>
>
>
>
> 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])


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com