@Test public void checkSomeNonPrimeNumbers() { int[] nonPrimes = new int[] { 4, 9, 16, 21, 30, 33, 42, 55, 100, 111, 129, 140 }; for (int nonPrime : nonPrimes) { assertFalse(nonPrime + " is detected as prime but is not prime.", Primality.isPrime(nonPrime)); } }
public static boolean isPrime(int x) { if (x <= 1) { return false; } int i = 2; while (i <= x && x % i != 0) { i++; } return i == x; }
Primality { public static boolean isPrime(int x) { if (x <= 1) { return false; } int i = 2; while (i <= x && x % i != 0) { i++; } return i == x; } }
Primality { public static boolean isPrime(int x) { if (x <= 1) { return false; } int i = 2; while (i <= x && x % i != 0) { i++; } return i == x; }  }
Primality { public static boolean isPrime(int x) { if (x <= 1) { return false; } int i = 2; while (i <= x && x % i != 0) { i++; } return i == x; }  static boolean isPrime(int x); }
Primality { public static boolean isPrime(int x) { if (x <= 1) { return false; } int i = 2; while (i <= x && x % i != 0) { i++; } return i == x; }  static boolean isPrime(int x);  }