public static void main(String[] args) { boolean b = primeNum(); System.out.println(b); } public static boolean primeNum() { int num = 0; Scanner scanner = new Scanner(System.in); if (scanner.hasNextInt()) { num = scanner.nextInt(); } for (int i = 2; i < num; i++) { if (num % i == 0) { return false; } } return true; }
判断质数
最新推荐文章于 2024-11-04 22:26:34 发布