gcd() takes a vector of whole numbers and returns their greatest common divisor as a numeric vector of length 1.

gcd(v)

Arguments

v

A vector of whole numbers

Value

Returns a numeric value corresponding to the greatest common divisor of the numbers in v.

Details

gcd() takes a vector, v, of whole numbers as argument and returns their greatest common divisor. Throws an error if any number in v is not a whole number (to within .Machine$double.eps^0.5).

Examples

gcd(c(48, 96, 144))
#> [1] 48