I'm solving this for a programming challenge, in fact I already solved it but I'd like to know if there's some kind of rule that could improve such thing?
For example if I needed the numbers divisible by 2,4 and 8, they are all multiples of 2, so I don't need to test each of them.
But, for 1 to 20, is this possible?