-
-
Save Alex-xd/3e3d95004ee192c1d2cfab53200fcd15 to your computer and use it in GitHub Desktop.
找出下面代码的规律并且编写一个函数,转换特定的整数到对应的字符串。
1 => A,2 => B,3 => C,...,26 => Z,27 => AA,28 => AB,29 => AC,...,52 => AZ,53 => BA,...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convert(num){ | |
var result = "" | |
while(num){ | |
result = String.fromCharCode( --num % 26 + 65) + result | |
num = Math.floor(num / 26) | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment