Guest User

Untitled

a guest
Mar 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. function printLabel(n) {
  12. if(n === 0) return 'Z';
  13.  
  14. if(n <= 26) return String.fromCharCode(64 + n);
  15.  
  16. var d = Math.floor(n / 26);
  17. var m = n % 26;
  18. if(m === 0) d -= 1;
  19.  
  20. var name = String.fromCharCode(64 + d) + printLabel(m);
  21.  
  22. return name;
  23. }
  24.  
  25. console.log(printLabel(26 * 26 + 26 + 1));
  26. </script>
  27.  
  28.  
  29.  
  30. <script id="jsbin-source-javascript" type="text/javascript">function printLabel(n) {
  31. if(n === 0) return 'Z';
  32.  
  33. if(n <= 26) return String.fromCharCode(64 + n);
  34.  
  35. var d = Math.floor(n / 26);
  36. var m = n % 26;
  37. if(m === 0) d -= 1;
  38.  
  39. var name = String.fromCharCode(64 + d) + printLabel(m);
  40.  
  41. return name;
  42. }
  43.  
  44. console.log(printLabel(26 * 26 + 26 + 1));</script></body>
  45. </html>
Add Comment
Please, Sign In to add comment