We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
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
}
Nice exercise - shout in lesson 2 the function is expected to be
sum_prime
, but the text asks forsumPrimes
. IMHO it should besum_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 befor i in 2..(number/2 + 1)
in lesson 2.