gcd {MiscMath} | R Documentation |
Greatest Common Divisor
Description
Greatest common divisor or factor for all elements of a positive-integer-valued vector.
Usage
gcd(x)
Arguments
x |
a numeric vector consisting of at least two positive integer values. |
Details
The gcd is calculated using the Euclidean algorithm applied to successive pairs of the elements of x.
Value
a numeric constant containing the greatest common divisor.
Examples
x <- c(81, 57, 333)
gcd(x)
[Package MiscMath version 1.1 Index]