Prime Checker

  • + 0 comments

    this is a very simple way to check PrimeNumber static class Prime {

        public boolean checkPrime(int num) {
            boolean isPrime = false;
            if (num == 2) {
                isPrime = true;
            }
            for (int i = 2; i < num; i++) {
                if (num % i == 0) {
                    isPrime = false;
                    break;
    
                } else if (num % i != 0) {
                    isPrime = true;
                }
    
            }
    
            return isPrime;
    
        }
    }