title: How does this Codechef Factorial Solution in C work?
body: <p>I'm trying to understand how this code: </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int j,p,k;
      long long int n,i;
      scanf("%lld",&amp;n);
      for(k=n;k&gt;=1;k--)
          {
              p=0;
              scanf("%lld",&amp;i);
              for (j=5;j&lt;=i;j*=5)
              {
                 p=p+i/j;
              }
              printf("%d\n",p);
          }
      return 0;
  } 
  </code></pre>
  
  <p>solves this Codechef problem: <a href="http://www.codechef.com/problems/FCTRL" rel="nofollow">http://www.codechef.com/problems/FCTRL</a></p>
  
  <p>What I'm having troubles understanding is how this loop works:</p>
  
  <pre><code>for (j=5;j&lt;=i;j*=5)
              {
                 p=p+i/j;
              }
  </code></pre>
  
  <p>Why is the <strong>j</strong> variable set to 5 and could someone walk me trough this loop if I would give the value of 60 to the <strong>i</strong> variable?</p>
  
  <p>Thanks so much!</p>