Originally Posted by

**undefined** So you have a set $\displaystyle S = \{a_1, a_2, ..., a_n\}$ and you want to find $\displaystyle lcm(a_1,a_2,...,a_n)$

The important thing to notice is that the exponent of a prime factor in the LCM will be the maximum of the set of exponents for that prime for all $\displaystyle a_i$.

So consider $\displaystyle S = \{2,3,4,7,14,16,22\}$ and let's just look at the prime factor 2. So the exponent of 2 in the lcm will be $\displaystyle max(1,0,2,0,1,4,1) = 4$.

Do you see how it applies?

In fact this problem (Project Euler problem #5) can be done with paper and pencil quite quickly if you think about it.