Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let wArab2Roman = t => {
- const r = {
- 1: "I",
- 10: "X",
- 5: "V",
- 50: "L",
- 100: "C"
- };
- let a = t => {
- let a = "",
- e = t.toString().split("");
- for (let l in e) t < 4 ? a += r[1].repeat(t) : 4 == t ? a += r[1] + r[5] : t > 4 && t < 9 ? a += r[5] + r[1].repeat(t - 5) : 9 == t ? a += r[1] + r[10] : a = r[10];
- return a
- },
- e = a(t);
- return t > 10 && t < 40 && (e = r[10].repeat(t.toString()[0]) + a(t.toString()[1])), e
- }
- let sayilar = "";
- for (let t = 1; t < 40; t++)
- sayilar += `wArab2Roman(${t}): ${wArab2Roman(t)}\n`;
- console.log("Sayilar:\n" + sayilar);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement