a side note, you can drastically reduce the work being done: you don't even need a loop.
the remainder vs the result...
say you want to know if something in 1234 to 1300 is divisible by 9.
1234 % 9 is 1
so we know that if we just added 1 to 1234, it would be divisible.
1235 / 9 = 137
and we know that 1235 is in the range asked for.
we are done. Do you understand this? Modulo is not well taught ... do you get what the remainder represents and why this is true? If you understand that... does anything change if your numbers are sometimes negative?
whole thing becomes if (a+a%c <= b) I believe, for positive input where a < b
typically you leave your question and its answers for others to enjoy. Deleting posts is usually seen as rude, unless the post is spam or unacceptable in some way.
> say you want to know if something in 1234 to 1300 is divisible by 9.
> 1234 % 9 is 1
> so we know that if we just added 1 to 1234, it would be divisible.
> 1235 / 9 = 137
you've got it backwards
you need to subtract 1 to 1234 so it would be divisible
1233 / 9 = 137
then you may do 1233 + 9 to get a number in the desired range.