Back to library index.

Package gcd (in gcd.i) -

Index of documented functions or symbols:

DOCUMENT factorize(x) return list of prime factors of X and their powers as an n-by-2 array. May include a large non-prime factor if X exceeds 3e9. In any event, product(result(,1)^result(,2)) will equal abs(X). X must be a scalar integer type.

DOCUMENT gcd(a,b) returns the GCD (greatest common divisor) of A and B, which must be one of the integer data types. A and B may be conformable arrays; the semantics of the gcd call are the same as any other binary operation. Uses Euclid's celebrated algorithm. The absolute values of A and B are taken before the operation commences; if either A or B is 0, the return value will be 0.

DOCUMENT is_prime(x) return non-zero if and only if X (which must be a scalar integer) is prime. May return a false positive if X is greater than about 3e9, since at most 20000 candidate factors are checked. The absolute value of X is taken first; zero is not prime, but 1 is.

DOCUMENT lcm(a,b) returns the LCM (least common multiple) of A and B, which must be one of the integer data types. A and B may be conformable arrays; the semantics of the lcm call are the same as any other binary operation. The absolute values of A and B are taken before the operation commences; if either A or B is 0, the return value will be 0.