# Python 3 program to convert Decimal
# number to Roman numbers.
import math
def integerToRoman(A):
romansDict =
{
1: "I",
5: "V",
10: "X",
50: "L",
100: "C",
500: "D",
1000: "M",
5000: "G",
10000: "H"
}
div = 1
while A >= div:
div *= 10
div //= 10
res = ""
while A:
# main significant digit extracted
# into lastNum
lastNum = (A // div)
if lastNum <= 3:
res += (romansDict[div] * lastNum)
elif lastNum == 4:
res += (romansDict[div] +
romansDict[div * 5])
elif 5 <= lastNum <= 8:
res += (romansDict[div * 5] +
(romansDict[div] * (lastNum - 5)))
elif lastNum == 9:
res += (romansDict[div] +
romansDict[div * 10])
A = math.floor(A % div)
div //= 10
return res
# Driver code
print("Roman Numeral of Integer is:"
+ str(integerToRoman(3549)))
class Solution {
public:
string intToRoman(int num) {
}
};
class Solution {
public String intToRoman(int num) {
}
}
char * intToRoman(int num){
}
public class Solution {
public string IntToRoman(int num) {
}
}
/**
* @param {number} num
* @return {string}
*/
var intToRoman = function(num) {
};
# @param {Integer} num
# @return {String}
def int_to_roman(num)
end
class Solution {
func intToRoman(_ num: Int) -> String {
}
}
class Solution {
/**
* @param Integer $num
* @return String
*/
function intToRoman($num) {
}
}
function intToRoman(num: number): string {
};