import java.io.*;
public class Prime
{
public static void main (String[] arqs)
{
Console console = System.console();
String sPrimenumber=console.readLine();
int iPrimenumber=Integer.parseInt(sPrimenumber);
if(primeNumber(iPrimenumber))
{
System.out.println("prime");
}
else
System.out.println("not prime");
}
static boolean primeNumber(int number)
{
for(int i=2;i
if(number%i==0)
{
return false;
}
}
return true;
}
}
import java.io.*;
public class Prime
{
public static void main (String[] arqs)
{
Console console = System.console();
String sPrimenumber=console.readLine();
int iPrimenumber=Integer.parseInt(sPrimenumber);
Number objNumber=new Number();
if(objNumber.testNumber(iPrimenumber))
{
System.out.println("prime");
}
else
System.out.println("not prime");
}
}
class Number
{
public boolean testNumber(int number)
{
for(int i=2;i
if(number%i==0)
{
return false;
}
}
return true;
}
}
============================================
No comments:
Post a Comment