HN2new | past | comments | ask | show | jobs | submitlogin

> 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?



That'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).


Do 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.


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: