We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

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.

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.

## Connecting Towns

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 equationandbefore assigning the result back to`sum`

is redundant.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.