c++ Number of zeros in a factorial number
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1174505/counting-trailing-zeros-of-numbers-resulted-from-factorial">Counting trailing zeros of numbers resulted from factorial</a>  </p>
</blockquote>



<p>It is given an integer "p". I have to find a number "n" for which "n factorial" has "p" numbers of zero at the end. Here is the solution i thought, but i am not sure if it is a solution for this problem. Do i have to make a function to calculate the factorial and another function to get the zeros?</p>

<pre><code>int p;
int count5=0;
int i;
int copy_i;

printf("Enter p: ");
scanf("%d",&amp;p);

for(i=1; ;i++)
{
    copy_i=i;

    while(copy_i/5)
    {
        if(copy_i%5==0)
        {
            count5++;
            copy_i=copy_i/5;
        }
        else
        {
            break;
        }
    }

    if(count5==p)
    {
        printf("The minimum number n is: %d.",i);
        break;
    }
    else if(count5&gt;p) 
    {
        printf("No match for n! with %d zero.",p);
        break;
    }

}
</code></pre>
