I was solving following problem on LCM : Calculate LCM of N numbers modulo 1000000007
My approach :
typedef unsigned long long ull;
your approach is wrong as mentioned by johnchen902.
Here is my approach:
for i=1 to n a.take i_th number as x b.reduce(devide) remaining numbers(i+1_th to n_th) by their gcd with x c.multiply x to ans and take mod of ans return ans
SEE AT IDEONE