mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #1589 (from nbraud:factor/gcd/test_divisor)
This commit is contained in:
commit
4b76849de7
1 changed files with 5 additions and 2 deletions
|
@ -72,11 +72,14 @@ mod tests {
|
||||||
gcd(1, a) == 1
|
gcd(1, a) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn zero(a: u64) -> bool {
|
||||||
|
gcd(0, a) == a
|
||||||
|
}
|
||||||
|
|
||||||
fn divisor(a: u64, b: u64) -> bool {
|
fn divisor(a: u64, b: u64) -> bool {
|
||||||
// Test that gcd(a, b) divides a and b
|
// Test that gcd(a, b) divides a and b
|
||||||
let g = gcd(a, b);
|
let g = gcd(a, b);
|
||||||
if g == 0 { return a == 0 && b == 0; }
|
(g != 0 && a % g == 0 && b % g == 0) || (g == 0 && a == 0 && b == 0)
|
||||||
a % g == 0 && b % g == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commutative(a: u64, b: u64) -> bool {
|
fn commutative(a: u64, b: u64) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue