klyn.math.Math.gcd
method
public static gcd<INT_TYPE extends AbstractInt>(left as INT_TYPE, right as INT_TYPE) as INT_TYPE
Description

Computes the non-negative greatest common divisor of two integers.

Parameters
ParameterDescription
leftThe first integer.
rightThe second integer.
Returns

The greatest common divisor, or zero if both inputs are zero.

Throws
  • ValueException if the final magnitude cannot fit in INT_TYPE.
Example
assert Math.gcd(42, 30) == 6