calculating modulo for large number

不问归期 提交于 2019-12-11 17:52:38

问题


All,

How can I calculate 2^301 mod 77? I did check out the link StackOverflow. But did not understand the step wherein 625 mod 221 = 183 mod 221. How did the conversion take place?


回答1:


Take a look at the question here for an answer to your question.

Basically, (X * Y) % Z == ((X % Z) * (Y % Z)) % Z.

So, as a starting point, 2^301 % 77 == ((2^150 % 77) * (2^151 % 77)) % 77. Keep splitting until you have reasonable numbers, then recombine. You will be able to keep your numbers at a reasonable size the whole way through.




回答2:


I don't understand the second part of your post, probably because you didn't include the link you actually followed. But your problem can be solved reading this page and implementing a proper algorithm of modular exponentiation



来源:https://stackoverflow.com/questions/4018321/calculating-modulo-for-large-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!