Блог пользователя OmaeWaMouShenDeiru

Автор OmaeWaMouShenDeiru, 9 лет назад, По-английски

hey guys :D

I have this small math problem,

( a * b ) mod n = 1

Given a, n:

find the smallest value of 'b' that satisfies the equation above.

any Idea about how to find the answer better than linear time search.

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +22 Проголосовать: не нравится
»
9 лет назад, # |
Rev. 3   Проголосовать: нравится +6 Проголосовать: не нравится

(a*b) mod n = 1 means that (a*b) = k*n+1 for some integer k>=0.

a*b-k*n = 1 is an equation of the form Ax+By=C which can be solved using Extended Euclidean algorithm.

Update: When I started writing my comment I didn't see that ikatanic has commented, sorry :)