gcd: Greatest common divisor.

View source: R/gcd.R

gcdR Documentation

Greatest common divisor.

Description

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

Usage

gcd(v)

Arguments

v

A vector of whole numbers

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).

Value

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

Examples

gcd(c(48, 96, 144))

davebraze/FDButils documentation built on Feb. 24, 2023, 12:14 a.m.