> For the complete documentation index, see [llms.txt](https://hannahpun.gitbook.io/leetcode-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hannahpun.gitbook.io/leetcode-note/dynamic-programing/168.-excel-sheet-column-title.md).

# # 168. Excel Sheet Column Title

[LeetCode](https://leetcode.com/problems/excel-sheet-column-title/)

```
/**
 * @param {number} n
 * @return {string}
 */

var convertToTitle = function(n) {
  var dict =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ];
    var result = '';
    if( n<=26 ){
        return dict[n-1];
    }
    while( n ){
        var val = (n-1)%26;
        result = dict[val] + result;
        n = Math.floor( (n-1) /26 );
    }
    return result;    
};
```
