Negative Number converting syntax in code

i don’t get it how sum=(sum+n)%5 in code converting negative numbers to positive(ex -2 to 2)
see ??? in code

Hey @rupesh-4819
Its not converting negative nos to positive
Instead its calculating modulo of negative nos

Say we have x%n then this should be equal to (x+0)%n == (x+n%n)%n ==(x+n)%n
In above example if n is 5 then (-2+5)%5=3

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.