Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Summarize-primes/Rust/summarize-primes.rust
Normal file
18
Task/Summarize-primes/Rust/summarize-primes.rust
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// [dependencies]
|
||||
// primal = "0.3"
|
||||
|
||||
fn main() {
|
||||
let limit = 1000;
|
||||
let mut sum = 0;
|
||||
println!("count prime sum");
|
||||
for (n, p) in primal::Sieve::new(limit)
|
||||
.primes_from(2)
|
||||
.take_while(|x| *x < limit)
|
||||
.enumerate()
|
||||
{
|
||||
sum += p;
|
||||
if primal::is_prime(sum as u64) {
|
||||
println!(" {:>3} {:>3} {:>5}", n + 1, p, sum);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue