title: Output powers of prime factors of a factorial
body: <p>I'm trying to write a code for my class. The program has to let the user input a number and it will output the exponents of each of the prime factors of its factorial. For example, when a user inputs the number 5, the output will be 3 1 1 (2^3, 3^1, 5^1). So far I have the code to get the prime factors of the factorial. But I can't get the exponents.</p>
  
  <p>My code is below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;windows.h&gt;
  using namespace std;
  
  int main()
  {
  int number, factor, exp, product, x, factorial=1;
  
  cout &lt;&lt;"PRIME FACTORIALS" &lt;&lt;endl;
  cout &lt;&lt;" " &lt;&lt;endl;
  cout &lt;&lt;"Welcome! This program allows users to find the prime factors of a number and its exponents or how many times each prime factor is multiplied." &lt;&lt;endl;
  cout &lt;&lt;" " &lt;&lt;endl;
  cout &lt;&lt;"To begin, please input a positive integer below:" &lt;&lt;endl;
  cin &gt;&gt;number;
  
  if ((number&lt;1) || (number&gt;100))
  {
      cout &lt;&lt;"You have entered a number that is out of range. Please enter a number from 1-100." &lt;&lt;endl;
      system("PAUSE");
      system("cls");
      main();
  }
  
  else
  {
      for (x=1; x&lt;=number; x++)
      {
          factorial=factorial*x;
  
          for (factor=2; factor&lt;=factorial; factor++)
          {
              while (factorial%factor==0)
              {
                  factorial/=factor;
                  cout &lt;&lt;factor &lt;&lt;" ";
              }
          }
      }
  }
  }
  </code></pre>