import java.util.Scanner; /** * */ /** * @author Harry * */ public class IsPrim { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.print("请输入所给数字:"); Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); //System.out.println(isPrim(num)); //IsPrim test = new IsPrim(); System.out.print(isPrim(num)); } private static boolean isPrim(int num){ if(num <1) return false ; if(num == 2) return true ; int i ; for(i = 2;i < num-1;i++){ if(num%i == 0){ System.out.print("并非质数"); return false; } } System.out.print("是质数"); return true; } }