Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes Sieve of Eratosthenes) only needs two nested loops.

The complexity of your algorithm is probably not optimal. On a modern computer, a simple implementation of the sieve should be able to calculate the number of primes below 1 million or 10 million almost instantly. How long does it take for you?

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes) only needs two nested loops.

The complexity of your algorithm is probably not optimal. On a modern computer, a simple implementation of the sieve should be able to calculate the number of primes below 1 million or 10 million almost instantly. How long does it take for you?

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes) only needs two nested loops.

The complexity of your algorithm is probably not optimal. On a modern computer, a simple implementation of the sieve should be able to calculate the number of primes below 1 million or 10 million almost instantly. How long does it take for you?

typo
Source Link
user140547
  • 479
  • 3
  • 8

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes) only needneeds two nested loops.

The complexity of your algorithm is probably not optimal. On a modern computer, a simple implementation of the sieve should be able to calculate the number of primes below 1 million or 10 million almost instantly. How long does it take for you?

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes) only need two nested loops.

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes) only needs two nested loops.

The complexity of your algorithm is probably not optimal. On a modern computer, a simple implementation of the sieve should be able to calculate the number of primes below 1 million or 10 million almost instantly. How long does it take for you?

added 2 characters in body
Source Link
user140547
  • 479
  • 3
  • 8

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implentationimplementation (which are also on this site, for example Sieve of Eratosthenes) only need two nested loops.

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implentation (which are also on this site, for example Sieve of Eratosthenes) only need two nested loops.

int [] numberList is probably redundant. AFAIK a standard implementation of the sieve needs only a boolean-array, as it is enough to store the information if a number is prime.

You have quite many (four) nested for-loops (3 with numberList.length, one with Math.sqrt(max)), this is most probably too complicated/slow/not needed. A simple implementation (which are also on this site, for example Sieve of Eratosthenes) only need two nested loops.

Source Link
user140547
  • 479
  • 3
  • 8
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /