Remainder operator query (Resolved)

Without seeing what is changing I it is hard to say. Have you printed the value of I before the if check to validate it has the expected value?

Please post the complete code if you can.