I was solving following problem on LCM : Calculate LCM of N numbers modulo 1000000007
My approach :
typedef unsigned long long ull;
The correct approach would be to prime factorize the elements of the array and keep track of the highest power of every prime for each element. LCM will be the product of these primes raised to their highest power in the array.