0

is there any more efficient way to get the LCM of a range of numbers in JAVA without using the BigInteger..?

I tried with the BigInteger and it worked, but i am looking for more efficient way to do this.

dpg
  • 1

1 Answers1

0
public static long lcm(long[] input) {
    long result = input[0];
    for(int i = 1; i < input.length; i++)
        result = lcm(result, input[i]);
    return result;
}

More info here.

Community
  • 1
  • 1
TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125