You are viewing a single comment's thread. Return to all comments →
BCoz it is a modulo property. (a*b)%c=((a%c)*(b%c))%c
That is the property, yes, but you can remove the first two modulos because a) x is between 1 and 1000, so x modulo 1234567 is pointless, and b) modulo-ing sum before it is used in the equation and before assigning the result back to sum is redundant.
x modulo 1234567
You are correct, but best practice may be to assume that inputs will not always be under 1000. Even though it says so in the question, it reduces future maintenance in a hypothetical.