4 ms·
> But if we multiply the numbers together we get a number that is divisible by every number in the table. Wouldn’t LCM be the correct/more general approach? Th
by Yajirobe 3y ago
> But if we multiply the numbers together we get a number that is divisible by every number in the table.
Wouldn’t LCM be the correct/more general approach? The periods could have common factors, right?
- tialaramex 3y agoThat's correct. In practice it appears that the AoC inputs provide numbers which are always co-prime (ie have no common factors other than 1).
- dunham 3y agoDo you know if there were any inputs on this problem that had non-prime numbers? Like others, I used LCM in my code, but mine were all prime numbers.
- tialaramex 3y agoI don't know, presumably Topaz (who creates AoC) would know, but isn't telling. We would probably find out if some inputs aren't co-prime because the naive multiplying solution breaks, but they could be non-prime and yet co-prime, for example 15, 14, 11, 23 is a set of numbers which are co-prime, but neither 15 nor 14 are prime.