Harshu2608's blog

By Harshu2608, history, 5 years ago, In English

If we Know the value of c where c=((a%mod)*(b%mod))%mod , the value of (a%mod) is given.How to find the value of (b%mod). a,b,c are integer and mod=1e9+7.

Example: mod=1e9+7 c=386724027 (a%mod)=787871 how to find the value of (b%mod)? ans=9192351 Can anyone help me to solve this?

  • Vote: I like it
  • +7
  • Vote: I do not like it

»
5 years ago, # |
Rev. 2   Vote: I like it +13 Vote: I do not like it

You can rewrite the expression as : $$$b = \frac{c}{a} \mod (10^9 + 7)$$$ = $$$c * a^{-1} \mod (10^9 + 7)$$$
The concept of $$$a^{-1}$$$ in a modular field is known as modular inverse.
You can learn about modular inverse here
For example, modular inverse of 787871 modulo $$$(10^9 + 7)$$$ equals 63215933.
When you multiply 63215933 with 386724027 modulo $$$(10^9 + 7)$$$, you will get back 9192351.