From ec404257b4cac7f77c4d646f1fec6c42e0b2fcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Thu, 12 Oct 2023 23:41:32 +0200 Subject: [PATCH] Remove redundant comments --- src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8ddf8e9..43deb85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -356,18 +356,15 @@ pub const fn moebius(x: core::num::NonZeroU64) -> i8 { let mut x = x.get(); let mut prime_count: u64 = 0; + // We avoid code repetition with the use of this macro. macro_rules! handle_factor { ($($factor:expr),+) => { $( - // If the given factor divides x if x % $factor == 0 { - // divide it out, x /= $factor; - // count it, prime_count += 1; - // and check if the factor still divides x. + // This checks if factor^2 divides x. if x % $factor == 0 { - // If it does then we return 0. return 0; } } @@ -375,10 +372,10 @@ pub const fn moebius(x: core::num::NonZeroU64) -> i8 { }; } - // Handle 2 and 3 separately + // Handle 2 and 3 separately, since the wheel will not find these factors. handle_factor!(2, 3); - // Handle the remaining factors <= √x with a wheel + // Handle the remaining factors <= √x with the wheel. let mut i = 5; let bound = isqrt(x); while i <= bound { @@ -392,7 +389,6 @@ pub const fn moebius(x: core::num::NonZeroU64) -> i8 { prime_count += 1; } - // Return 1 or -1 depending on whether x has an even or odd number of prime factors. if prime_count % 2 == 0 { 1 } else {