title: Program showing false positives for Prime Numbers
body: <p>After compiling all numbers are showing Prime. Please point out any type of logical errors.</p>
  
  <pre><code>int i, num, res;
  boolean flag = false;
  Scanner sc = new Scanner(System.in);
  System.out.println("Enter number for Prime:");
  num = sc.nextInt();
  
  for(i = 2; i &lt;= num / 2; i++) {
      res = num % 2;
      if(res == 0) {
          flag = false;
          break;
      }
      else flag = true;
  }
  if(flag = true)
      System.out.println("Prime No.");
  else
      System.out.println("Not a Prime No.");
  </code></pre>