import java.util.Scanner;

public class PrimeCheck {

  public static void main(String[] args) {
    long count,number,maxcheck;
    Scanner scan = new Scanner(System.in);

    do {
        System.out.print("Enter the number to check: ");
        number = scan.nextLong();
        if (number<2)
            System.out.println("It must be greater than 1.");
    } while(number<2);

    // see if it is prime
    // for this we check to see if it's divisible by any
    // number between 2 and its square root
    // note the cast to convert the double result into an integer
    maxcheck = (long)Math.sqrt(number);

    // assume it is prime unless we prove otherwise
    boolean isPrime = true;
    count = 2;
    while (count<=maxcheck) {
      if (number%count==0) {
        // divides evenly: not prime
        isPrime = false;
      }
      count++;
    }

    System.out.println("Your number "+number+
                       ((isPrime)? " is" : " is not")+" prime.");
  }
}
