Here is a Java Program to Find whether given number is a Prime Number or not.
Output of Above Java Program
Prime
class FindPrime { public static void main(String args[]) { int num; boolean isPrime = true; num = 157; for(int i=2; i <= num/2; i++) { if((num % i) == 0) { isPrime = false; break; } } if(isPrime) System.out.println("Prime"); else System.out.println("Not Prime"); } }
Output of Above Java Program
Prime