Skip to content

Commit

Permalink
improve some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Oct 12, 2023
1 parent 4250962 commit b05bca9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,16 @@ pub const fn moebius(x: core::num::NonZeroU64) -> i8 {

let mut prime_count = 0;

// Handle 2 and 3 separately
// Handle 2 separately
if x % 2 == 0 {
x /= 2;
prime_count += 1;
// If 2^2 is also a divisor of x
if x % 2 == 0 {
return 0;
}
}
// Same for 3
if x % 3 == 0 {
x /= 3;
prime_count += 1;
Expand Down Expand Up @@ -400,7 +402,7 @@ pub const fn moebius(x: core::num::NonZeroU64) -> i8 {
}

// If x is a prime it will never be divided by any factor less than its square root.
// In that case x is still larger than one, and we must count it.
// In that case we can check if x is still larger than one, and then count it.
if x > 1 {
prime_count += 1;
}
Expand Down

0 comments on commit b05bca9

Please sign in to comment.