We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd925c2 commit ece0ac3Copy full SHA for ece0ac3
src/year2017/day23.rs
@@ -51,7 +51,7 @@
51
//! [`Day 18`]: crate::year2017::day18
52
use crate::util::parse::*;
53
54
-/// We only need the vrey first number from the input.
+/// We only need the very first number from the input.
55
pub fn parse(input: &str) -> u32 {
56
input.unsigned()
57
}
@@ -69,7 +69,10 @@ pub fn part2(input: &u32) -> usize {
69
/// Simple [prime number check](https://en.wikipedia.org/wiki/Primality_test)
70
/// of all factors from 2 to √n inclusive.
71
fn composite(n: u32) -> Option<u32> {
72
- for f in 2..=n.isqrt() {
+ if n % 2 == 0 {
73
+ return Some(n);
74
+ };
75
+ for f in (3..).step_by(2).take_while(|m| m * m <= n) {
76
if n % f == 0 {
77
return Some(n);
78
0 commit comments