Java Utililty Methods lcm

List of utility methods to do lcm

Description

The list of methods to do lcm are organized into topic(s).

Method

intlcm(int x1, int x2)
Method that calculates the Least Common Multiple (LCM) of two strictly positive integer numbers.
if (x1 <= 0 || x2 <= 0) {
    throw new IllegalArgumentException("Cannot compute the least " + "common multiple of two "
            + "numbers if one, at least," + "is negative.");
int max, min;
if (x1 > x2) {
    max = x1;
    min = x2;
...
longlcm(long a, long b)
Calculates lowest common multiple (LCM) of two integer values a and b
return (a * b) / gcd(a, b);
longlcm(long a, long b)
lcm
return a * (b / gcd(a, b));
longlcm(long a, long b)
lcm
return a * b / gcd(a, b);
longlcm(long u, long v)
lcm
return (u / gcd(u, v)) * v;
longlcm(long x, long y)
lcm
return x * y / gcd(x, y);
longlcm(long[] a)
lcm
if (a.length == 1) {
    return a[0];
} else {
    long lcm = 1;
    for (int i = 0; i < a.length; i++) {
        if (i == 0) {
            lcm = lcm(a[i], a[i + 1]);
        } else {
...
longLCM1(int A, int B)
LCM
long lowestCommonMultiple = A * B;
int curNum = 0;
int indexA = 1;
int indexB = 1;
int curA = 1;
int curB = 1;
while (curNum < (A * B)) {
    curA = A * indexA;
...
intlcmPositive(int... args)
Returns the least common multiple of the given absolute values.
if (args == null || args.length < 2)
    throw new IllegalArgumentException("lcmPositive requires at least two arguments");
int result = args[0];
int n = args.length;
for (int i = 1; i < n; i++) {
    result = lcmPositive(result, args[i]);
return result;
...