I know how to compute modular multiplicative inverses for co-prime variables a and b, but is there an efficient method for computing variable x where x<b and a and b are not co-prime, given variables a, b and c, as described by the equation below?
ax≡cmodb
For example, given
154x≡14mod182, is there an efficient method for computing all the possibilities of x, without pure bruteforce?
Please note that I'm not necessarily asking for a direct solution, just a more optimized one.
I do not believe that the Extended Euclidean Algorithm will work here, because a and b are not co-prime.
Edit:
Follow up question, since the first one had a shortcut:
Could the be computed efficiently as well?
12260x≡24560mod24755.
107 needs to be one of the computed answers.
Answer
Below we compute x≡2456012260(mod24755) per your edit, by the method in my first answer.
mod 24755: 024755⌢≡2456012260⌢≡390235⌢≡428040⌢≡−535−5⌢≡00
i.e. mod24755: [[1]] 24755x≡ 0 [[2]] 12260x≡ 24560≡−195[[1]]−2[[2]]→[[3]] 235x≡ 390 [[2]]−52[[3]]→[[4]] 40x≡ 4280 [[3]]−6[[4]]→[[5]] −5x≡−535 [[4]]+8[[5]]→[[6]] 0x≡ 0
Therefore x≡5355(mod24755)≡107(mod4951), via canceling 5≡107+4951k(mod24755), 0≤k≤4≡{107,5058,10009,14960,19911}(mod24755)
No comments:
Post a Comment