All problems

Problem 87

Excel Column Title

Easy · 10 pts · Math, String

Problem

Spreadsheet columns are named A, B, ..., Z, then AA, AB, ..., AZ, BA, ..., ZZ, then AAA, and so on. Column 1 is A, column 26 is Z, column 27 is AA and column 28 is AB. Given a column number N, print its title. This is like writing N in base 26, except that the digits run from 1 (A) to 26 (Z) with no zero. So at each step subtract 1 first: the last letter is (N - 1) mod 26, mapped to A to Z, and then N becomes (N - 1) / 26. Repeat until N is 0 and reverse the letters.

Input

A single integer N.

Output

Print the column title.

Constraints

1 <= N <= 2147483647

Example input

1

Example output

A

Explanation

For N = 1: (1 - 1) mod 26 = 0, which is the letter A, and then (1 - 1) / 26 = 0 ends the loop. So the title is A.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Excel Column Number Next: Binomial Coefficient Modulo