與正確輸出不相符(line:10)
您的答案為: 質數
正確答案為: 非質數
也不知道機器是怎麼Run程式碼的
不知道是哪個數字出錯= =
import java.util.Scanner;
public class Prime {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
long a = 2;
label :
while(sc.hasNext()){
a = sc.nextLong();
if(a == 2 || a == 3 || a == 5 || a == 7 || a == 11 || a == 13 || a == 17 || a == 19){
System.out.println("質數");
continue label;
}
for(int i = 2; i <= 19; i= (i==2)? i+1 : (i==7)? i+4 : (i==13)? i+4 : i+2){
for(long j = i; j <= a; j *= i){
if( a % j == 0){
System.out.println("非質數");
continue label;
}
}
}
System.out.println("質數");
}
}
}