If n is not within k of the maximum unsigned integer:<p><pre><code>  i = n+k;
  do {
    i -= k;
    ...
  } while (i &gt;= k);
</code></pre>
If n is close enough to the maximum unsigned integer for n+k to overflow:<p><pre><code>  i = n;
  goto skip_sub;
  do {
    i -= k;
  skip_sub:
    ...
  } while (i &gt;= k);</code></pre>