請判斷某數是否為質數
import java.util.Scanner;
public class a007 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int i,x;
while(input.hasNext()){
x=input.nextInt();
for (i=2;i<=Math.sqrt(x);i++){
if(x%i==0){
System.out.println("非質數");
break;
}
}
if(i>Math.sqrt(x)){
System.out.println("質數");
}
}
}
}