题解 | #判断质数#
判断质数
https://www.nowcoder.com/practice/4d2a100c2e544f56ac1ad17e9ffa107d
import java.util.Scanner; public class Main { public static void main(String[] args) { Main main = new Main(); Scanner scan = new Scanner(System.in); int number = scan.nextInt(); System.out.println(main.isPrimeNumber(number)); } public Boolean isPrimeNumber(int number) { int num = 0; for(int i = 1;i <= number;i++){ if(number%i==0){ num += 1; } } if(num==2){ return true; } return false; } }