In the last video modulo properties prateek bhaiya said
(b-a)%n = ( (b%n)-(a%n) + n) %n;
but in this video we have (b-a)%n = 0;
and he says it implies > b%n = a%n
instead of > (b%n) + n = (a%m) which we get by using the above property
In the last video modulo properties prateek bhaiya said
(b-a)%n = ( (b%n)-(a%n) + n) %n;
but in this video we have (b-a)%n = 0;
and he says it implies > b%n = a%n
instead of > (b%n) + n = (a%m) which we get by using the above property
Hi anas … the first property is just to avoid negative values inside modulo. It is equal since u open that up n%n becomes = 0. That’s why (b-a)%n = ( (b%n)-(a%n) + n) %n ( Notice this modulo outside ) . Its to wrap evrything up. Its just a safety measure.
But when we say (b-a)%n = 0 . Her u cannot write it (b%n) + n = (a%n) this way because in the equation above notice the outermost %n … You can’t just ignore that right??
Its like : - ((b%n) + n)%n = (a%n)
Now they are equal.