tests ~ (sub-crate factor) refactor divisor() test for improved readability

This commit is contained in:
Roy Ivy III
2020-10-26 15:06:29 -05:00
parent ae06368cd8
commit 114fda0519
+5 -1
View File
@@ -79,7 +79,11 @@ mod tests {
fn divisor(a: u64, b: u64) -> bool {
// Test that gcd(a, b) divides a and b
let g = gcd(a, b);
(g != 0 && a % g == 0 && b % g == 0) || (g == 0 && a == 0 && b == 0)
if g != 0 {
a % g == 0 && b % g == 0
} else {
a == 0 && b == 0 // for g == 0
}
}
fn commutative(a: u64, b: u64) -> bool {