Doubt in modulo arithmetic

( (a%m)+(b%m) )%m; // if say, x

( ( ( (a%m)+(b%m) )%m )+m)%m; // then (x+m) % m

Like the second formula is more general than 1st one can you please provide more general form for following (div / sub) :

// for SUB
((a%m)-(b%m)+m)%m;

// for DIV
((a%m)*( B %m))%m; // B is mult. inverse

Refer to This

i am closing this doubt now
you can ask query in above link

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.