Opening Hours :7AM to 9PM
import java.util.Scanner; public class PrimeNumber { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a number: "); int num = sc.nextInt(); boolean isPrime = true; // Check if the number is less than 2. if (num < 2) { isPrime = false; } else { // Check if the number is divisible by any number from 2 to the square root of the number. for (int i = 2; i <= Math.sqrt(num); i++) { if (num % i == 0) { isPrime = false; break; } } } if (isPrime) { System.out.println(num + " is a prime number"); } else { System.out.println(num + " is not a prime number"); } } }