import java.io.*;
public class Prime{
public static void main(String[] args) throws IOException {
BufferedReader jill = new BufferedReader (new InputStreamReader (System.in));
boolean isPrime = true;
System.out.print("Enter number: ");
int input = Integer.parseInt(jill.readLine());
if(input < 2){
isPrime = false;
}
if (input == 2) {
isPrime = true;
}
if (isPrime)
for (int y=3; y<=(input/2); y+=2)
if(input == 3){
isPrime = true;
break;
}
else if (input % y == 0)
{
isPrime = false;
break;
}
if (isPrime)
System.out.println("That is a prime number.");
else{
System.out.println("That is not a prime number.");
}
}
}
// i was able to determine whether it is a prime number or not. but my problem is i want to count how many prime number in a given range..
//exampe: the user gave range 10. there are 4 prime numbers: 2, 3, 5, and 7..
..//help me!