Java Prime
public class Prime {
public static boolean isPrime(int num) {
if (num<2)
return false;
for(int i=3;i<=Math.sqrt(num);i+=2)
if(num%i==0)
return false ;
return true ;
}
}
public class Prime {
public static boolean isPrime(int num) {
if (num<2)
return false;
for(int i=3;i<=Math.sqrt(num);i+=2)
if(num%i==0)
return false ;
return true ;
}
}
public static boolean isPrime(int n) {
for (int i = 2; i <= Math.sqrt(n); i++)
if (n % i == 0) return false;
return n > 1;
}