Here you can find the source of lcm(BigInteger... nums)
public static BigInteger lcm(BigInteger... nums)
//package com.java2s; //License from project: Apache License import java.math.BigInteger; import java.util.Arrays; public class Main { public static BigInteger lcm(BigInteger... nums) { return lcm(Arrays.asList(nums)); }/* w w w . j av a 2s . c o m*/ public static BigInteger lcm(Iterable<BigInteger> nums) { BigInteger ret = null; for (BigInteger num : nums) { if (ret == null) { ret = num; } else { ret = lcm(ret, num); } } return ret; } public static BigInteger lcm(BigInteger num1, BigInteger num2) { return num1.multiply(num2.divide(num1.gcd(num2))); } public static BigInteger gcd(Iterable<BigInteger> nums) { BigInteger ret = null; for (BigInteger num : nums) { if (ret == null) { ret = num; } else { ret = ret.gcd(num); } } return ret; } }