import java.io.*; import java.util.Scanner; public class Test { public static void main(String[] args) { while (true) { int i = 0; try { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); System.out.print("Please enter a number:"); for (i = 2; i <= num; i++) { if (num % i != 0) continue; else break; } if (i == num) { System.out.println("是素数"); } else { System.out.println("不是素数"); } } catch (Exception e) { System.out.println("您输入的不是数字"); } } } }
求采纳