0

write a program to find whether the number is prime or not.

2nd Sep 2016, 8:22 AM
punam
4 Respuestas
+ 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; }
7th Sep 2016, 7:52 PM
Zen
Zen - avatar
0
if no. is divisible by 2,3,5, and 7, i.e. remainder 0,,print "not prime"..else otherwise..
2nd Sep 2016, 9:42 AM
Raj Joshi
Raj Joshi - avatar
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"); }
11th Oct 2016, 5:49 PM
Afia Irfan Beg
Afia Irfan Beg - avatar
0
zara difficult questions karo na aap :/ :/
17th Feb 2017, 11:18 PM
khaled khan
khaled khan - avatar