Calculate the modular inverse of $2a$ given that of $a$

42 Views Asked by At

My problem is that I have to calculate some modular inverses of numbers that are related by multiplying by $2$, that is:

Given $a$ and $x$ so that $ax\equiv1\mod n$ ($n$ being an odd number) I need to calculate $x'$ so that $2ax'\equiv 1 \mod n$

By some testing I have found that the formula: $$x' = x + \frac{n-x}{2}$$ seem to apply.

Is this formula correct, or is it just that for the particular cases that I have tried apply? And if it is incorrect, is there a general formula for solving my problem?

Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

One has $(ab)^{-1}= a^{-1}b^{-1}$ (assuming all inverses exist). Thus with $b=2$ and noting $2^{-1}= (n+1)/2$, you get $$x (n+1)/2 $$ as the inverse. This is congruent to what you have, as $x$ must be odd and thus $(x-1)n/2 =0$.