package com.sunnyykn.algorithm;
public class Prime {
private static final int MAX = 100000;
private static int i;
private static int j;
private static int array[] = new int[MAX];
public static void main(String[] args) {
for (i = 0; i < MAX; i ++) {
array[i] = i;
}
for (i = 2; i < Math.sqrt(MAX); i ++) {
for (j = i * i; j < MAX; j += i) {
array[j] = 0;
}
}
for (i = 0; i < MAX; i ++) {
if (array[i]!= 0 && array[i] != 1) {
System.out.println(array[i]);
}
}
}
}
Prime
最新推荐文章于 2021-03-12 00:54:24 发布