Tag: sieve of eratosthenes

Eratosthenes Sieve问题Java

我遇到了一个需要使用数组的赋值问题。 我需要创建Sierat of Eratosthenes算法并打印出所有素数。 我很困惑,因为据我所知,我的操作顺序是正确的。 这是代码: //Declare the array boolean numbers [] = new boolean[1000]; int y = 0; //Declare all numbers as true to begin for(int i = 2; i < 1000;i++){ numbers[i] = true; } //Run loop that increases i and multiplies it by increasing multiples for (int x = 2; x < […]