title: Some numbers are incorrectly changed when i try to find prime numbers in matrix
body: <p>I try to find prime numbers in a matrix and replace then with 1 and 0 respectively. For some the output is correct but for some it isn't and it doesn't change the last element. Can't figure out what's causing this. Looked up formulas for finding prime numbers they use the same loop as i do.</p>
  
  <pre><code>int main() {
      int m, n;
      scanf("%d %d", &amp;m, &amp;n);
  
      int a[m][n];
  
      for(int i = 0; i &lt; m; i++) {
          for(int j = 0; j &lt; n; j++) {
              scanf("%d", &amp;a[i][j]);
          }
      }
  
  
      for(int i = 0; i &lt; m; i++) {
          for(int j = 0; j &lt; n; j++) {
              for(int k = 2; k &lt; a[i][j]; k++) {
                  if(a[i][j] % k == 0) {
                      a[i][j] = 0;
                  } else if(a[i][j] % k != 0){
                      a[i][j] = 1;
                  }
          }
      }
  }
  </code></pre>
  
  <p>Input:</p>
  
  <p><code>15 23 7 10
   6 18 5 31
   31 14 1 2</code></p>
  
  <p>Output im getting:</p>
  
  <p><code>1 1 1 0
   0 0 1 1
   1 0 1 2</code></p>
  
  <p>Output i need to get:</p>
  
  <p><code>0 1 1 0
   0 0 1 1
   1 0 0 1</code></p>