Previous Page | Next Page

Functions and CALL Routines

GCD Function



Returns the greatest common divisor for one or more integers.
Category: Mathematical

Syntax
Arguments
Details
Examples
See Also

Syntax

GCD(x1, x2, x3, ..., xn)


Arguments

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.


Examples

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:

LCM Function

Previous Page | Next Page | Top of Page