We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Anonymous • 4 years ago

Nice exercise - shout in lesson 2 the function is expected to be sum_prime, but the text asks for sumPrimes. IMHO it should be sum_primes (notice the plural).
Additionally, the answers where pre-filled in the text boxes.

And: The test in lesson 1 lets for i in 2..(number/2) pass, while it must be for i in 2..(number/2 + 1) in lesson 2.

Anonymous • 4 years ago

is_prime in a more functional style could be:

pub fn is_prime(number: i32) -> bool {
match number {
1 => {return false}
_ => {
(2..number/2).into_iter().map(|n| number%n == 0).fold(true, |acc, n| acc && n);
}
}
return true
}