How this happen as the property is(a-b)%n=((a%n)-(b%n)+n)%n
Regarding b%n=a%n
Hey @Hk199977 it possible that even tho a is greater than b, but a%n is smaller than b%n for example if a = 8, b = 4 and n = 7. a is greater than b but a%n i.e 1 is smaller than b%n i.e 4 which will make the term inside modulo negative. So to avoid that we add n which returns the correct solution.
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.