Compute the greatest common divisor of two integers.
Numeric.math.gcd(first, right)Combines operands with NumPy style broadcast.
- Parameters:
first: First operand as a scalar, vector, or matrixright: Second operand as a scalar, vector, or matrix
- Returns: Divisors matching the broadcast shape of the operands
- NumPy: Equivalent to
np.gcd.
import Numeric from '@neabyte/numerix'
const divisor = Numeric.math.gcd(12, 18)
console.log(divisor)
// 6import Numeric from '@neabyte/numerix'
const divisors = Numeric.math.gcd([12, 8], [18, 12])
console.log(divisors)
// [6,4]import Numeric from '@neabyte/numerix'
const divisor = Numeric.math.gcd(7, 13)
console.log(divisor)
// 1import Numeric from '@neabyte/numerix'
const divisor = Numeric.math.gcd(9, 9)
console.log(divisor)
// 9