0
write a program to find whether the number is prime or not.
4 odpowiedzi
+ 1
public static boolean isPrime(int n) {
if (n < 2) {
return false;
}
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
0
if no. is divisible by 2,3,5, and 7, i.e. remainder 0,,print "not prime"..else otherwise..
0
public static void main(int n)
{
if(n%2==0)
System.out.println(" the no. is not prime") ;
else
System.out.println(" the no. is prime");
}
0
zara difficult questions karo na aap :/ :/