提交 7cf1f554 编写于 作者: G Graham Fawcett

In sieve example, end iteration sooner

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.
上级 e6cfb56a
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册