Skip to content

Commit

Permalink
auto merge of #17888 : gmfawcett/rust/patch-1, r=alexcrichton
Browse files Browse the repository at this point in the history
The Sieve algorithm only requires checking all elements up to and including the square root of the maximum prime you're looking for. After that, the remaining elements are guaranteed to be prime.
  • Loading branch information
bors committed Oct 13, 2014
2 parents 36d0346 + 7cf1f55 commit 1c3ddd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
//! bv.set(0, false);
//! bv.set(1, false);
//!
//! for i in range(2, max_prime) {
//! for i in iter::range_inclusive(2, (max_prime as f64).sqrt() as uint) {
//! // if i is a prime
//! if bv[i] {
//! // Mark all multiples of i as non-prime (any multiples below i * i
Expand Down

0 comments on commit 1c3ddd2

Please sign in to comment.