import java.util.Scanner;
class Prime
{
int n;
//To initialize values
Prime(int no)
{
n=no;
}
//To check number is prime or not
void check()
{
int i;
boolean flag=true;
for(i=2;i<n/2;i++)
{
if(n%i==0)
{
flag=false;
break;
}
}
if(flag==true)
{
System.out.println(n+" is Prime ");
}
else
{
System.out.println(n+" is not Prime ");
}
}
}
//To create object
class TestPrime
{
public static void main(String args[])
{
int n;
Scanner input=new Scanner(System.in);
System.out.println("\nEnter number :- ");
n=input.nextInt();
Prime obj=new Prime(n);
obj.check();
}
}
0 Comments