Improving the algorithm

Figure 316. Implementation observation Slide presentation
101 / 2  = 50 remainder 1
101 / 3  = 33 remainder 2
101 / 4  = 25 remainder 1
101 / 5  = 20 remainder 1
101 / 6  = 16 remainder 5
101 / 7  = 14 remainder 3
101 / 8  = 12 remainder 5
101 / 9  = 11 remainder 2
101 / 10  = 10 remainder 1
101 / 11  = 9 remainder 2
101 / 12  = 8 remainder 5
101 / 13  = 7 remainder 10
...

Figure 317. Changing the implementation Slide presentation

Big performance gain:

public static boolean isPrime(int value) {
  for (int i = 2; i * i < value; i++) {
    if (0 == value % i) {
      return false;
    }
  }
  return value != 1;
}

Figure 318. Regression test Slide presentation
Regression test

Figure 319. Systematic error debugging Slide presentation

Figure 320. Error correction in detail Slide presentation
public static boolean isPrime(int value) {

//for (int i = 2; i * i < value; i++) {
  for (int i = 2; i * i <= value; i++) {
    if (0 == value % i) {
      return false;
    }
  }
  return value != 1;
}