title: Why does quot need to be repeatedly subtracted by 1?
body: <p>This question is based off this thread <a href="https://stackoverflow.com/questions/763691/programming-riddle-how-might-you-translate-an-excel-column-name-to-a-number">Programming Riddle: How might you translate an Excel column name to a number?</a></p>
  
  <p>Here is code from that question to translate a column number to an excel column name</p>
  
  <pre><code>public String getColName (int colNum) {
  
     String res = "";
     int quot = colNum;
     int rem;        
      /*1. Subtract one from number.
      *2. Save the mod 26 value.
     *3. Divide the number by 26, save result.
     *4. Convert the remainder to a letter.
     *5. Repeat until the number is zero.
     *6. Return that bitch...
     */
      while(quot &gt; 0)
      {
          quot = quot - 1;
          rem = quot % 26;
          quot = quot / 26;
  
          //cast to a char and add to the beginning of the string
          //add 97 to convert to the correct ascii number
          res = (char)(rem+97) + res;            
      }   
      return res;
  }
  </code></pre>
  
  <p>I tested this code thoroughly and it works but I have a question about what this line needs to be repeated for this to work </p>
  
  <pre><code>            quot = quot - 1;
  </code></pre>
  
  <p>From my understanding the quot is needed to map the col number to distance away from 'a'. That means 1 should map to 0 distance from 'a', 2 to 1 distance away from 'a' and so on. But don't you need to subtract this one once to account for this? Not in a loop
  I mean eventually,</p>
  
  <pre><code>            quot = quot / 26;
  </code></pre>
  
  <p>will stop the loop.</p>