Find the given Number is Prime number or Not

Check Given Number is Prime Number or Not

What is the Prime number?

A prime number is a whole number greater than 1, whose only two whole-number factors are 1 and itself. The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.

Here is the Java Program to Find the Given number is Prime or not

public class PrimeNum

{

public static void main(String args[])

{

int n=13,count=0;

for(int i=2;i<=n;i++)

{

if(n%i==0)

{

count=count+1;

}

}

if(count>=2)

System.out.println(“not prime”);

else

System.out.println(“prime”);

}

}

output: Prime 
Next program To Know the palandrum Number

Leave a Reply