Welcome to Vestris Inc.
Internet Interactive Solutions Company



Software Documentation

Gcd

Name

Gcd — greatest common divisor

Syntax

Gcd( expression , ... , expression )

Domain

Gcd : Z x Z -> Z

Example

Gcd( 3213 , 24 ) = 3

Description

Calculates the greatest common divisor between a list of expressions. The greatest common divisor is the biggest number that divides each of the arguments to produce a result in Z. In the example above, 3213 / 3 = 1071 and 24 / 3 = 8.

The famous Euclide's algorithm to find the greatest common divisor is:
while ( x != 0 ) {
  t = x mod y;
  x = y;
  y = t;
}
Gcd = x;