package com.example.mode.sort;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class PrimeNumber {
public PrimeNumber() {
}
public static void main(String [] args){
List<Integer> mList = new ArrayList<Integer>();
for (int i = 2; i < 1000; i++) {
if (isPrimeNum(i)){
mList.add(i);
}
}
System.out.println(mList.toString());
}
private static boolean isPrimeNum(int i) {
for (int j = 2; j <=Math.sqrt(i); j++) {
if (i%j == 0){
return false;
}
}
return true;
}
}
网友评论