title: prime factorization of factorial in C
body: <p>I'm trying to write a program that will print the factorial of a given number in the form:
  10!=2^8 * 3^4 * 5^2 * 7
  To make it quick lets say the given number is 10 and we have the prime numbers beforehand. I don't want to calculate the factorial first. Because if the given number is larger, it will eventually go beyond the the range for int type. So  the algorithm i follow is: 
  First compute two’s power.  There are five numbers between one and ten that two divides into.  These numbers are given 2*1, 2*2, …, 2*5.  Further, two also divides two numbers in the set {1,2,3,4,5}.  These numbers are 2*1 and 2*2.  Continuing in this pattern, there is one number between one and two that two divides into.  Then a=5+2+1=8.</p>
  
  <p>Now look at finding three’s power.  There are three numbers from one to ten that three divides into, and then one number between one and three that three divides into.  Thus b=3+1=4.  In a similar fashion c=2.  Then the set R={8,4,2,1}.  The final answer is:</p>
  
  <p>10!=2^8*3^4*5^2*7</p>
  
  <p>So what i wrote is:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  main()
   {
       int i, n, count;
       int ara[]={2, 3, 5, 7};
       for(i=0; i&lt;4; i++)
       {
           count=0;
           for(n=10; n&gt;0; n--)
           {
              while(n%ara[i]==0)
              {
                  count++;
                  n=n/ara[i];
              }
           }
           printf("(%d^%d)" , ara[i], count);
       }
       return 0;
     }
  </code></pre>
  
  <p>and the output is (2^3) (3^2) (5^1) (7^1).
  I can't understand what's wrong with my code. Can anyone help me, please?</p>