{
"topic": "decimal-roman",
"input_types": [
"int"
],
"input_labels": [
"Decimal"
],
"input_values": [
149
],
"type": "Convert",
"title": "Decimal to Roman",
"category": "Numbers",
"function": "function myFunc(arr) {\n var x = parseInt(arr[0]);\n if (isNaN(x) || x < 0 || !Number.isInteger(x)) return \"Invalid input.\";\n const romanNumerals = [[1000, 'M'],[900, 'CM'],[500, 'D'],[400, 'CD'],[100, 'C'],[90, 'XC'],[50, 'L'],[40, 'XL'],[10, 'X'],[9, 'IX'],[5, 'V'],[4, 'IV'],[1, 'I']];\n var result = '';\n for (let i=0; i<romanNumerals.length; i++) {\n let rN = romanNumerals[i];\n while (x >= rN[0]) {\n result += rN[1];\n x -= rN[0];\n if(x==0) break;\n }\n if(x==0) break;\n }\n return result;\n }",
"op_label": "Roman",
"explanation": "This converter converts the given decimal number to roman.",
"content": "<p>Decimal to Roman conversion is the process of converting a decimal (base-10) number into its Roman numeral representation.</p><h2>Steps to Convert Decimal to Roman</h2><p>Here are the steps to convert a decimal number to a Roman numeral:</p><ol class=\"steps\"><li>Identify the largest Roman numeral that is less than or equal to the given decimal number.</li><li>Write down the corresponding Roman numeral letter.</li><li>Subtract the value of the Roman numeral from the decimal number.</li><li>Repeat steps 1-3 until the decimal number becomes 0.</li></ol><h2>Example</h2><p>Let's take an example to illustrate the process. Suppose we want to convert the decimal number <strong>149</strong> to a Roman numeral:</p><ol class=\"steps\"><li>The largest Roman numeral less than or equal to 149 is C (100).</li><li>Write down C.</li><li>Subtract 100 from 149, and we get 49.</li><li>Repeat the process: the largest Roman numeral less than or equal to 49 is XL (40).</li><li>Write down XL.</li><li>Subtract 40 from 49, and we get 9.</li><li>Repeat the process: the largest Roman numeral less than or equal to 9 is IX (9).</li><li>Write down IX.</li><li>Subtract 9 from 9, and we get 0.</li></ol><p>The Roman numeral equivalent is <strong>CXLIX</strong>.</p><p>Therefore, <strong>149</strong> in decimal is equal to <strong>CXLIX</strong> in Roman numerals.</p>"
}