title: Stop loop once if value is met one time
body: <p>I have a for loop checking the result of value % i. Inside, there is an if statement checking if value % i = 0. If it does equal zero, it sets boolean isDivisible to true. If it returns a nonzero it sets isDivisible to false. The issue is that, for example, if the value is 12, <em>some</em> attempts will return 0 while some will be nonzero, so isDivisible is constantly changing inaccurately. I want the loop to end once value % i = 0. Is such a thing possible? </p>
  
  <pre><code>for (int i=2; i &lt; value; i++){
              if (value % i == 0){
                  isDivisible = true;
              }
              else{
                  isDivisible = false;
              }
          }
          if (isDivisible = true){
                  System.out.println(value + " is prime");
              }
  </code></pre>