title: Prime Factorization
body: <p>So my professor has us writing a program that fines the prime facotrization of a number given by the user. And provide the answer in exponents. So if your number was 96, I have the program listing out like this 2 x 2 x 2 x 2 x 3. He would like us to have it listed out like this. 2^5 x 3^1. How would I go about doing this?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
  
      int i, n;
  
      // Get the user input.
      printf("Please enter a number.\n");
      scanf("%d", &amp;n);
  
      // Print out factorization
      printf("The prime factorization of %d is ", n);
  
      // Loop through, finding prime factors.
      int cur_factor = 2;
      while (cur_factor &lt; n) {
  
          // Found a factor.
          if (n%cur_factor == 0) {
              printf("%d x ", cur_factor);
              n = n/cur_factor;
          }
  
          // Going to the next possible factor.
          else
              cur_factor++;
      }
  
      // Prints last factor.
      printf("%d.\n", cur_factor);
  
      return 0;
  }
  </code></pre>