package Test;
import java.util.*;
public class tests {
/**测试
* @param args
*/
public static void main(String[] args) {
System.out.println("请输入一个正整数:");
int a = (new Scanner(System.in)).nextInt();
if(isPrimeNumber(a) == true){
System.out.println(a+"是素数");
}
else{
System.out.println(a+"不是素数");
}
}
public static boolean isPrimeNumber(int number){
boolean flag=true;
if(number<=0)
throw new IllegalArgumentException("number是不合法的参数!");
for(int i=2;i<=Math.sqrt(number);i++){
if(number%i==0)
flag=false;
if(flag==false)
break;
}
return flag;
}
}