Skip to content

Instantly share code, notes, and snippets.

@Alex-xd
Created September 13, 2016 05:01
Show Gist options
  • Save Alex-xd/3e3d95004ee192c1d2cfab53200fcd15 to your computer and use it in GitHub Desktop.
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,...
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