要求:
传入参数:10,返回:false
传入参数:11,返回:true
public static void main(String[] args) { demo count = new demo(); Scanner scan = new Scanner(System.in); System.out.println("请输入数字"); int n = scan.nextInt(); if (count.ss(n)){ System.out.println("素数"); }else { System.out.println("不是素数"); } } public static Boolean ss(int x ){ boolean flag = true; for (int i = 2;i<x;i++){ if (x%i==0){ flag = false; break; } } return flag; }