The simplest solution, which works because the constraints are so low, is best here: loop from min to max and check each number to see if it is devisable by factor.
If you want to get more efficient, you can increment min until you hit a number divisible by factor, decrement max until you hit a number divisible by factor, then subtract min from max, divide factor and add 1. that's it.
No comments:
Post a Comment