# gcd: Greatest Common Divisor (GCD) and Least Common Multiple (LCM) In gmp: Multiple Precision Arithmetic

## Description

Compute the greatest common divisor (GCD) and least common multiple (LCM) of two (big) integers.

## Usage

 ```1 2 3``` ```## S3 method for class 'bigz' gcd(a, b) lcm.bigz(a, b) ```

## Arguments

 `a,b` Either integer, numeric, `bigz` or a string value; if a string, either starting with `0x` for hexadecimal, `0b` for binary or without prefix for decimal values.

## Value

An element of class bigz

Antoine Lucas

## References

The GNU MP Library, see http://gmplib.org

`gcdex`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10``` ```gcd.bigz(210,342) # or also lcm.bigz(210,342) a <- 210 ; b <- 342 stopifnot(gcd.bigz(a,b) * lcm.bigz(a,b) == a * b) ## or (a <- as.bigz("82696155787249022588")) (b <- as.bigz("65175989479756205392")) gcd(a,b) # 4 stopifnot(gcd(a,b) * lcm.bigz(a,b) == a * b) ```

### Example output

```Attaching package: 'gmp'

The following objects are masked from 'package:base':

%*%, apply, crossprod, matrix, tcrossprod

Big Integer ('bigz') :
[1] 6
Big Integer ('bigz') :
[1] 11970
Big Integer ('bigz') :
[1] 82696155787249022588
Big Integer ('bigz') :
[1] 65175989479756205392
Big Integer ('bigz') :
[1] 4
```

gmp documentation built on May 29, 2017, 5:44 p.m.