title: Number of divisiors upto 10^6
body: <p>I have been trying to solve this problem.</p>
  
  <p><a href="http://www.spoj.com/problems/DIV/" rel="nofollow">http://www.spoj.com/problems/DIV/</a></p>
  
  <p>for calcuating interger factors, I tried two ways</p>
  
  <p>first: normal sqrt(i) iteration.</p>
  
  <pre><code>int divCount = 2;
              for (int j = 2; j * j &lt;= i ; ++j) {
                  if( i % j == 0) {
                          if( i / j == j )
                              divCount += 1;
                          else
                              divCount += 2;
                      }
              }
  </code></pre>
  
  <p>second: Using prime factorization (primes - sieve)</p>
  
  <pre><code>for(int j = 0; copy != 1; ++j){
                  int count = 0;
                  while(copy % primes.get(j) == 0){
                      copy /= primes.get(j);
                      ++count;
                  }
                  divCount *= ( count + 1);}
  </code></pre>
  
  <p>While the output is correct, I am getting TLE. Any more optimization can be done? Please help. Thanks </p>