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

Автор code_warrior, история, 6 лет назад, По-английски

Hello, freinds recently i was confronted with a problem which goes like this->

Given a positive odd prime number p and another positive integer k (1<k<=p-1) find the minimum value of m such that pow(k,m)%p=1.

One straight way of approaching this is to iterate untill we get what we need thus contributing a time complexity of O(p), but i fancy if there exists even a more efficient way to do so. Can anyone help me or give some clue of how to solve it in less than O(p) time complexity.

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

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Although it now seems to me that it has to don something with euler tuoteint function but couldn't figure it out! xD.

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

claim: $$$m=p-1$$$. If possible let there exist smallest $$$r \lt p-1$$$ s.t. $$$k^r \equiv 1\,mod\,p.$$$ Since $$$p \gt r$$$ so $$$p=rq+r_1 \,\, ,r_1 \lt r$$$ for some integer $$$q$$$. Now $$$k^{p-1} \equiv k^{rq+r_1-1} \equiv k^{r_1-1} \equiv 1\, mod\, p. (k^{p-1} \equiv 1\,mod\,p)$$$(by LFT) so we got a contradiction that r was smallest since we found $$$r_1-1 \lt r$$$. Hence $$$m=p-1$$$