Scanner sr = new Scanner(System.in); System.out.print("请输入a的值:"); int a = sr.nextInt(); boolean is = true; if (a < 1) { System.out.println(a + "不是质数,因为他小于一"); } else { List
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
Scanner c = new Scanner(System.in);
System.out.println("请输入一个大于3的整数:");
int num = c.nextInt();
for(int i=2;i<=num/2;i++){
if(num%i==0){
System.out.println(num+"不是素数");
}else{
System.out.println(num+"是素数");
}
}
}
}