finding a^b^c^… mod m

前端 未结 6 1808
慢半拍i
慢半拍i 2020-11-29 23:53

I would like to calculate:

abcd... mod m

Do you know any efficient way since this number

6条回答
  •  天命终不由人
    2020-11-30 00:24

    abc mod m = abc mod n mod m, where n = φ(m) Euler's totient function.

    If m is prime, then n = m-1.

    Edit: as Nabb pointed out, this only holds if a is coprime to m. So you would have to check this first.

提交回复
热议问题