Rust Implementation of Problem 10

View source code here on GitHub!

Includes

Problem Solution

pub fn problems::p0010::p0010() -> utils::Answer
 1/*
 2Project Euler Problem 10
 3
 4This one was also relatively easy, especially given the work I have
 5done on my prime number infrastructure.
 6
 7Problem:
 8
 9The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
10
11Find the sum of all the primes below two million.
12*/
13use crate::include::primes::primes;
14use crate::include::utils::Answer;
15
16pub fn p0010() -> Answer {
17    return Answer::Int(
18        primes::<u64>()
19            .take_while(|&p| p < 2000000)
20            .sum::<u64>()
21            .into()
22    );
23}

Tags: prime-number, rust-iterator