I am trying to calculate LCM of n numbers using prime factorisation method

i have written code for 4 numbers

i just want to know that what is the more efficient way or if my method is optimized??

- first i am finding prime factors of given number
- then i am using a max array to hold the maximum power of esch prime factor
- and then i am using these values to calculate lcm

P.S I got this method from

http://discuss.codechef.com/questions/47240/sgarden-editorial

thanks…