Skip to content

Commit 1c3ddd2

Browse files
committed
auto merge of #17888 : gmfawcett/rust/patch-1, r=alexcrichton
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.
2 parents 36d0346 + 7cf1f55 commit 1c3ddd2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcollections/bitv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! bv.set(0, false);
3434
//! bv.set(1, false);
3535
//!
36-
//! for i in range(2, max_prime) {
36+
//! for i in iter::range_inclusive(2, (max_prime as f64).sqrt() as uint) {
3737
//! // if i is a prime
3838
//! if bv[i] {
3939
//! // Mark all multiples of i as non-prime (any multiples below i * i

0 commit comments

Comments
 (0)