Let's say I have an expression $$$x = k_1\cdot k_2 \cdot \cdot \cdot k_n \% MOD$$$.

Where $$$MOD$$$ is a prime number .

Now I want to divide $$$x$$$ with some $$$k_i\cdot k_j$$$ and I want to mutliply $$$x$$$ with some $$$p$$$ and $$$q$$$ .

Then is it true that $$$x = x{*}MODINV(k_i{*}k_j , MOD -2){*}p{*}q$$$ .

Why Downvote him? He is simply asking for help.

Answer -> yes, you are right. but mod inverse should be with respect to mod and not mod — 2. And you forgot to take mod over whole value and at some intermediate steps Thanks.

Thanks a lot StayAwayFromBitches .

Actually that MODINV meant to be power that was a mistake and I am taking the mod of whole where I am implementing it .

Thanks again .