title: Finding factors of a number. Not getting accurate results
body: <p>Can someone help correct my algorithm?  I've tested it on a few numbers, and it doesn't output the complete factorization.  For numbers with a large number of factors, it just completely fails.</p>
  
  <pre><code>int num = 20;
  
  for(int i = 2; i &lt;= num; i++)
  {
      if(num%i == 0)
      {
          cout &lt;&lt; i &lt;&lt; endl;
          cout &lt;&lt; num &lt;&lt; endl;
          num = num/i;    
      }
  }
  </code></pre>
  
  <p>EDIT: The two answers provided did not work, still not getting full results.</p>
  
  <p>EDIT2: Divisors VS Factors</p>