Practice Question 3

Home / Java Practice Question / Practice Question 3

Practice Question 3


Question 3. Write a Program to check the given number is a prime number or not.

Program


class Solution{

    static int isPrime(int N){

        if(N == 1) return 0; 

        for(int i=2; i*i<=N; i++) {

             if(N%i == 0) {

                return 0 ;

             }

        }

        return 1;

    }

}