Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

GCD

GCD and LCM Integer Functions


Description

Greatest common divisor and least common multiple

Usage

GCD(n, m)
LCM(n, m)

mGCD(x)
mLCM(x)

Arguments

n, m

integer scalars.

x

a vector of integers.

Details

Computation based on the Euclidean algorithm without using the extended version.

mGCD (the multiple GCD) computes the greatest common divisor for all numbers in the integer vector x together.

Value

A numeric (integer) value.

Note

The following relation is always true:

n * m = GCD(n, m) * LCM(n, m)

See Also

Examples

GCD(12, 10)
GCD(46368, 75025)  # Fibonacci numbers are relatively prime to each other

LCM(12, 10)
LCM(46368, 75025)  # = 46368 * 75025

mGCD(c(2, 3, 5, 7) * 11)
mGCD(c(2*3, 3*5, 5*7))
mLCM(c(2, 3, 5, 7) * 11)
mLCM(c(2*3, 3*5, 5*7))

numbers

Number-Theoretic Functions

v0.8-1
GPL (>= 3)
Authors
Hans Werner Borchers
Initial release
2021-04-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.