Skip to content

Commit

Permalink
Remove redundant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Oct 12, 2023
1 parent 816122e commit ec40425
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,29 +356,26 @@ 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;
}
}
)+
};
}

// 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 {
Expand All @@ -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 {
Expand Down

0 comments on commit ec40425

Please sign in to comment.