Finding the number of divisors?
<p>I wrote this code in order to find the number of the divisors of a given number. The method I am trying to implement finds all of the prime factors (which works) and takes number of similar prime numbers plus one (which gives the number of divisors).</p>

<p>e.g. 28 = 2*2 * 7 --> (2+1)*(1+1) = 6</p>

<p>This is my attempt:</p>

<pre><code>int num = 20;
int next = 0;
int exponent = 0;
int numberOfDivisors = 1;

    start:
        for (int i = 2; i &lt;= num; i++)
        {
            next = i;

            if (num%i == 0)
            {   
                if (i == next)
                {
                    exponent++; 
                }
                else
                {
                    numberOfDivisors *= (exponent+1);
                    exponent = 0;
                }

                if (num != i)
                {
                    num /= i;
                    goto start;
                }
            }
        }

    std::cout &lt;&lt; numberOfDivisors &lt;&lt; std::endl;
</code></pre>

<p>I just cannot figure out what I am missing.</p>
