Converting Decimal Number lying between 1 to 3999 to Roman Numerals | Function to calculate roman equivalent ; storing roman values of digits from 0 - 9 when placed at different places ; Converting to roman ; Driver program to test above function
function intToRoman ( num ) { let m = [ " " , " " , " " , " " ] ; let c = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; let x = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; let i = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; let thousands = m [ Math . floor ( num / 1000 ) ] ; let hundereds = c [ Math . floor ( ( num % 1000 ) / 100 ) ] ; let tens = x [ Math . floor ( ( num % 100 ) / 10 ) ] ; let ones = i [ num % 10 ] ; let ans = thousands + hundereds + tens + ones ; return ans ; } let number = 3549 ; document . write ( intToRoman ( number ) ) ;