[英]Calculate power with large number in matlab
I want to calculate for example 257^150 but matlab shows until 257^126. 我想计算例如257 ^ 150,但matlab会显示到257 ^ 126。 I want to find the exponent "x" in order to compute the modulus. 我想找到指数“ x”以计算模量。 For example the power which gives (257^x mod 1009) = 369. Thanks. 例如,给出(257 ^ x mod 1009)= 369的功率。谢谢。
Think about the problem and how you would solve it. 考虑问题以及如何解决。 You know hat mod(x,42)
is 23
. 您知道hat mod(x,42)
是23
。 What is the remainder of 7*x
? 7*x
的余数是多少? Its mod(7*42,23)
它的mod(7*42,23)
Put into code: 放入代码:
a=257;
m=1009;
s=369;
r=1;
x=0;
while(not(r==s))
x=x+1;
r=mod(r*a,m);
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.