Answers for "prime check jaba"

1

prime check jaba

static boolean isPrime(int n){
        boolean result=true;
        if(n <= 1) return false;
        for(int i = 2; i <= n/2; i++){
            if(n % i == 0){
                result = false; //if some number divides it, then prime=false;
                break;
            }
        }
        return result;
    }
Posted by: Guest on September-03-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language