29: Improve solution for Rust track exercise "Nth Prime".
[?]
Aaw9nJhsNmfzFih9mKyNw9mV8CgERXJkRa1kK1Kx3LQH
Sep 2, 2021, 9:09 AM
IXMBS6ZPQSFG6HTYGHNJJ3YK2KYGUBBNTMIU7Q5CAKLJEXSBP4EACDependencies
- [2]
EUWYCVLU17: Improve solution for Rust track exercise "Nth Prime". - [3]
KWE5K6XL23: Fix panix on input `12` for solution for Rust track exercise "Nth Prime". - [4]
UTP7D53Q12: Improve solution for Rust track exercise "Nth Prime". - [5]
ERYD4CD711: Add solution for Rust track exercise "Nth Prime". - [*]
JZN2AQ3E10: Add Rust track exercise "nth-prime".
Change contents
- edit in rust/nth-prime/src/lib.rs at line 6
* Skips even numbers. - replacement in rust/nth-prime/src/lib.rs at line 28
0,1, - replacement in rust/nth-prime/src/lib.rs at line 31
for index in 2..limit {(2_usize.pow(2)..list_size).step_by(2).for_each(|multiple| {list[multiple] = false;});for index in (3..limit).step_by(2) { - edit in rust/nth-prime/src/lib.rs at line 41
}for multiple in (index * index..list_size).step_by(index) {list[multiple] = false; - edit in rust/nth-prime/src/lib.rs at line 42
(index.pow(2)..list_size).step_by(index).for_each(|multiple| {list[multiple] = false;}); - replacement in rust/nth-prime/src/lib.rs at line 50
for index in limit..list_size {if list[index] {if limit & 1 == 1 {for index in (limit..list_size).step_by(2) {if list[index] {count += 1;if count > n {// Might return incorrect value if values greater than u32::MAX are cast.return index as u32;}}}} else {if list[limit] { - replacement in rust/nth-prime/src/lib.rs at line 65
return index as u32;return limit as u32;}}for index in ((limit + 1)..list_size).step_by(2) {if list[index] {count += 1;if count > n {// Might return incorrect value if values greater than u32::MAX are cast.return index as u32;}