title: Integer factorization, code isn't responding
body: <p>I'm facing an issue where my code seems to misbehave - the cursor is blinking in the terminal, but the code isn't responding, it's stuck.
  I tried to do some debugging, but couldn't figure out what's causing it to happen.</p>
  <p>Here's my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      int prim[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71},szam,i=0;
      printf(&quot;Kerek egy szamot!\n&quot;);
      scanf(&quot;%d&quot;,&amp;szam);
      while(szam!=1)
      {
          if(szam%prim[i]==0)
          {
              szam=szam/prim[i];
              printf(&quot;%d*&quot;,prim[i]);
          }
          else
          {
              if(szam%prim[i]!=0)
              {
                  prim[i]=prim[i+1];
              }
          }
      }
      printf(&quot;1&quot;);
      return 0;
  }
  </code></pre>
  <p>Basically, what it should do for an integer input is (as the title suggests integer factorization).
  I went through various inputs on a sheet and checked what would happen according to my code.</p>
  <p>For input = 40 it should execute the first while loop, then step into the if clause, then get divided by 2, and output <code>2*</code>. Skip the else part and enter the while loop again since 20 not equals with 1. Again, should get divided by 2, and output another <code>2*</code>, repeat the same process one more time, by now outputting <code>2*2*2*</code>, and for the 4th iteration, it should enter the else clause, as the input has reduced to 5. Then execute the if clause, increase value of &quot;i&quot; by 1, and since the value of the input should remain 5, iterate the else clause again. Then increase the value of &quot;i&quot; by 1 again, which points to the third element of the array by now, which is 5. Now that both values are the same (input and &quot;i&quot;), it should do the first if clause one more time and output <code>2*2*2*5*1</code>.
  The code is never showing the requested <code>1</code> before the <code>return 0;</code>, which makes me think it gets stuck inside the <code>while</code> loop.</p>
  <p>Any help is highly appreciated.
  Thank you in advance.</p>