Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有计算模乘逆的问题。例如我有整数A = 151和M = 541。151 mod 541. inverse mod 151 to 541 is 43 如何在matlab中计算模乘逆?
A = 151
M = 541
这可以使用gcd和mod函数来完成,如下所示:
gcd
mod
A = 151; M = 541; [G, C, ~] = gcd(A,M); if G==1 % The inverse of a(mod b) exists only if gcd(a,b)=1 ModMultInv = mod(C,M) else disp('Modular multiplicative inverse does not exist for these values') end
输出:-
ModMultInv = 43