Write a function that accepts an integer argument and checks if the number is
prime. Write a function that keeps count of number of times it’s been invoked
public class Main {
public static int count = 0;
public static void count() {
count++;
}
public static boolean isPrime(int value) {
count();
for (int i = 2; i < value + 1; i++) {
for (int j = i * i; j < value + 1; j += i) {
if (j == value) {
return false;
}
}
}
return true;
}
}
Comments
Leave a comment