Learn R Programming

pracma (version 0.2-2)

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