GCD Function

Returns the greatest common divisor for one or more integers.

Category: Mathematical

Syntax

Required Argument

x

specifies a numeric constant, variable, or expression that has an integer value.

Details

The GCD (greatest common divisor) function returns the greatest common divisor of one or more integers. For example, the greatest common divisor for 30 and 42 is 6. The greatest common divisor is also called the highest common factor.
If any of the arguments are missing, then the returned value is a missing value.

Example

The following example returns the greatest common divisor of the integers 10 and 15.
data _null_;
   x=gcd(10, 15);
   put x=;
run;
SAS writes the following output to the log:
x=5

See Also

Functions: