The number conversion you've shown doesn't seem consistent. It seems you want to convert a number to the equivalent spreadsheet column letter, similar to this Python question: Convert spreadsheet number to column letter.
Converting that code to javascript (and cleaning up a bit) gives:
function numToSSColumn(num){
var s = '', t;
while (num > 0) {
t = (num - 1) % 26;
s = String.fromCharCode(65 + t) + s;
num = (num - t)/26 | 0;
}
return s || undefined;
}
// A Z AA CZ DA YZ ZZ AAA
[0,1,26,27,104,105,676,702,703,
//AAZ ABA AZZ BAA BAZ BBA YYYZ ZZZZ
728,729,1378,1379,1404,1405,456976,475254].forEach(function(n) {
console.log(n + ' : ' + numToSSColumn(n));
});
The function doesn't check the input and returns undefined if n < 0
.
Your conversions don't seem to work because spreadsheet columns don't start from 0, they start from 1, so A-Z is 1 to 26, AA to AZ is 27 to 52, and so on. 676 is YZ and 456976 is YYYZ. ZZZZ is 475254 (or 11110 base26);