我想计算一下:
abcd... mod m
你知道有什么有效的方法吗,因为这个数字太大了,但 a 、 b 、 c 、...和 m 适合一个简单的 32 位 int 。
有任何想法吗?
Caveat: This question is different from finding ab mod m.
Also please note that abc is not the same as (ab)c. The later is equal to abc. Exponentiation is right-associative.
abc mod m = abc mod n mod m, where n = φ(m) Euler's totient function http://en.wikipedia.org/wiki/Euler's_totient_function.
如果 m 是素数,则 n = m-1。
编辑:正如 Nabb 指出的,这仅在 a 与 m 互质时成立。所以你必须先检查一下。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)