Orac And LCM explanation

Hi everyone, I was doing the Orac and LCM problem on the Gold Divisibility topic. I got the problem right but I could not understand how the internal sol computed the answer without finding the prime factorization of each number. Could someone help explain it?

Thanks in advance

If it’s hard to understand what exactly this code is doing at first glance, a
good first step is to simulating the code in the case where each a_i is a
power of the same prime (say, 2^k). If the algorithm works for this case, then
it will also work in the general case since the contributions of different
primes are computed independently and multiplied together.