title: c++ Increasing for loop increment logarithmically
body: <p>I want to loop though integers like this:</p>
  
  <p>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, ..., 100, 200, ..., 1000, 2000, ... </p>
  
  <p>I have code to do this (shown below) however it is cumbersome and not programmed generally to deal with different stopping limits:</p>
  
  <pre><code>int MAX = 10000;
  
  for (int i = 1; i &lt;= MAX; i++) {
  
      cout &lt;&lt; i &lt;&lt; endl;
  
      if (i &gt;= 10 &amp;&amp; i &lt; 100) {
          i += 9;
      }
  
      else if (i &gt;= 100 &amp;&amp; i &lt; 1000) {
          i+= 99;
      }
  
      else if (i &gt;= 1000 &amp;&amp; i &lt; 10000) {
          i += 999;
      }
  
  }
  </code></pre>
  
  <p>As you can see, this is very situation specified as mentioned previously - so I'd like to know of a way to code this in a more general way, as for my requirements MAX will be of the order of 10^9 so using code like above is far too impractical.</p>