Definition and lemmas for gcd and lcm over Int
Future work #
Most of the material about Nat.gcd and Nat.lcm from Init.Data.Nat.Gcd and Init.Data.Nat.Lcm
has analogues for Int.gcd and Int.lcm that should be added to this file.
gcd #
Computes the greatest common divisor of two integers as a natural number. The GCD of two integers is
the largest natural number that evenly divides both. However, the GCD of a number and 0 is the
number's absolute value.
This implementation uses Nat.gcd, which is overridden in both the kernel and the compiler to
efficiently evaluate using arbitrary-precision arithmetic.
Examples:
Instances For
lcm #
Computes the least common multiple of two integers as a natural number. The LCM of two integers is the smallest natural number that's evenly divisible by the absolute values of both.
Examples:
Int.lcm 9 6 = 18Int.lcm 9 (-6) = 18Int.lcm 9 3 = 9Int.lcm 9 (-3) = 9Int.lcm 0 3 = 0Int.lcm (-3) 0 = 0