Programming! - Get the Code
package com.amanmehara;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("isPrime? ");
System.out.println();
Scanner consoleInput = new Scanner(System.in);
System.out.println("Enter the number to be checked");
long number = consoleInput.nextLong();
System.out.println();
boolean isPrime=true;
//Prime number checker
for (int i=2;i<=Math.sqrt(number);i++) {
if (number % i == 0) {
isPrime = false;
break;
}
}
if(isPrime) {
System.out.println("It is a Prime Number.. !!");
}
else {
System.out.println("Not a Prime Number.. !!");
}
System.out.println();
}
}