// simple_check_prime_number
import java.io.*;
class simple_check_prime_number
{
public static void main(String args[])
{
try
{
int i,no,a=1;
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter the number to check it is prime or not");
no=Integer.parseInt(cin.readLine());
for(i=2;i<no;i++)
{
if(no%i==0)
{
a=0;
break;
}
else
{
a=1;
}
}
if(a==1)
{
System.out.println(no+" is prime");
}
else
{
System.out.println(no+" is not prime");
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
}
No comments:
Post a Comment