Advertisement
Guest User

Arab to Roman

a guest
Dec 9th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let wArab2Roman = t => {
  2.     const r = {
  3.         1: "I",
  4.         10: "X",
  5.         5: "V",
  6.         50: "L",
  7.         100: "C"
  8.     };
  9.     let a = t => {
  10.             let a = "",
  11.                 e = t.toString().split("");
  12.             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];
  13.             return a
  14.         },
  15.         e = a(t);
  16.     return t > 10 && t < 40 && (e = r[10].repeat(t.toString()[0]) + a(t.toString()[1])), e
  17. }
  18.  
  19. let sayilar = "";
  20. for (let t = 1; t < 40; t++)
  21.     sayilar += `wArab2Roman(${t}): ${wArab2Roman(t)}\n`;
  22. console.log("Sayilar:\n" + sayilar);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement