Learn R Programming

pracma (version 1.1.6)

GCD, LCM: GCD and LCM Integer Functions

Description

Greatest common divisor and least common multiple

Usage

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

Arguments

n, m
integer scalars

Value

  • a numeric (integer) value

Details

Computation based on the extended Euclidean algorithm in extGCD.

See Also

extGCD, coprime

Examples

Run this code
GCD(12, 10)
GCD(46368, 75025)  # Fibonacci numbers are relatively prime to each other
LCM(12, 10)
LCM(46368, 75025)  # = 46368 * 75025

Run the code above in your browser using DataLab