Javascript Number toBijectiveBase26 =(function()

Description

Javascript Number toBijectiveBase26 =(function()


Number.prototype.toBijectiveBase26 = (function () {
  return function toBijectiveBase26() {
    n = this/*from   w ww  .  jav  a  2s .c om*/
    ret = "";
    while(parseInt(n)>0){
      --n;
      ret += String.fromCharCode("A".charCodeAt(0)+(n%26));
      n/=26;
    }
    return ret.split("").reverse().join("");
  };
}());



PreviousNext

Related