title: there is some sort of error in the syntax of the program "to determine whether the number is prime or not" in JAVA
body: <p>Even if I input the number &quot;4&quot;, it shows that the number is prime. Please help to find error in the syntax. I have written below the program I coded :</p>
  <p>int n  = sc.nextInt();</p>
  <pre><code>boolean isPrime = true;
  
  for (int i = 2;  i &lt; n; i = i + 1)
  {if (n % i == 0) {
      isPrime = false;
      break;}
  }
  
  if (isPrime = true) 
      System.out.println(&quot;the number is prime&quot;);
  
  else if (isPrime = false)
  System.out.println(&quot;the number is not prime&quot;);
  </code></pre>