第1个回答 2017-08-17
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class NewClass {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入您要输入的整数:");
int test = in.nextInt();
boolean flag = true;
for(int i=2;i<test;i++){
if(test%i==0){
System.out.println("该整数不是质数");
flag = false;
break;
}
}
if(flag){
System.out.println("该整数是质数");
}
}
}本回答被网友采纳