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.
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.
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.