static Object lcm(Object args) { long L = 1, g = 1; while (args is Pair) { long n = Math.Abs((long)num(first(args))); g = gcd2(n, L); L = (g == 0) ? g : (n / g) * L; args = rest(args); } return num(L); }