Roman Numeral Conversion

I would like to use a roman numeral as my copyright year.  What is the conversion code I need to use?
Who is Participating?
tecbuilderConnect With a Mentor Commented:
I developed this for a pascal program I wrote quite a while ago and later converted it to JavaScript to convert any integer to Roman Numeral and Roman Numeral to integer.  I believe it will do what you want.

function convertInteger(N) {
  var valRN = new Array (1,4,5,9,10,40,50,90,100,400,500,900,1000);
  var textRN = new Array ("I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M");
  var theValue = "";
  while (N > 0) {
    i = 12;
    while(valRN[i] > N) i--;
    numRN = Math.floor(N / valRN[i]);
    for (j=1;j<=numRN;j++) theValue += textRN[i];
    N = N % valRN[i];
  return theValue;

// -->

document.write("Copyright &copy; " + convertInteger(2000));


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.