title: Factor table algorithm with complexity O(n·sqrt(n))
body: <p>The following code prints a table of the factors of each number from 0 to <em>n</em>. Can someone help me rewrite the following O(n²) time code so that it has complexity O(n·sqrt(n)) time ?</p>
  
  <p>I actually rewrote the algorithm to have O(n·log n) but I can't figure it out for that complexity.</p>
  
  <pre><code>public static Vector&lt;Vector&lt;Integer&gt;&gt; factTable(int n) {
    Vector&lt;Vector&lt;Integer&gt;&gt; table = new Vector&lt;Vector&lt;Integer&gt;&gt;();
    for (int i = 1;i &lt;= n; i++) {
      Vector&lt;Integer&gt; factors  =  new  Vector&lt;Integer&gt;();
      for  (int  f  =  1;  f  &lt;=  i;  f++) {
        if  ((i  %  f)  ==  0)  
        factors.add(f);
      }
    table.add(factors);
    }
    return  table;
  }
  </code></pre>