Documentation
gcd :: N -> N -> N Source #
greatest common divisor.
Properties For all a
and b
in N
holds:
gcd a b ==
gcd b a
.gcd a b ==
0
if and only if a ==
0
and b ==
0
.gcd a 0 ==
a
.gcd a 1 ==
1
.gcd a b *
lcm
a b ==
a *
b
.
gcds :: [N] -> N Source #
greatest common divisor of the given list.
Note gcds [] ==
0
.
lcm :: N -> N -> N Source #
least common multiple.
Properties For all a
and b
in N
holds:
lcm a b ==
lcm b a
.lcm a b ==
1
if and only if a ==
1
and b ==
1
.lcm a 0 ==
0
.lcm a 1 ==
a
.gcd
a b *
lcm a b ==
a *
b
.
euclid :: Z -> Z -> (N, Z, Z) Source #
extended euclidean algorithm to determine the greatest cowmon divisor.
Properties (g,s,t) = euclid
a b
then
g
is the greatest common divisor of a
and b
.g ==
s *
a +
t *
b
.
(//) :: Z -> N -> Z infix 7 Source #
extended division in Z
by a dividend in N
.
Properties For all z
and n
holds:
0 // 0 ==
1
.- if
z /=
0
then z // 0 ==
0
. - if
0 <
n
then z // n ==
div
z n
. z ==
(z // n) *
inj
n +
mod0
z n
.