gcd: Greatest Common Divisor

View source: R/gcd.R

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

MiscMath documentation built on April 13, 2025, 9:07 a.m.