solvlincong.m

来自「Mathematical Methods by Moor n Stiling.」· M 代码 · 共 19 行

M
19
字号
function x = solvlincong(a,m,b) 
% 
% Ddetermine the solution to the linear congruence
% a x equiv b (mod m), if it exists
%
% function x = solvlincong(a,m,b)

% Copyright 1999 by Todd K. Moon

[g,x,y] = gcdint2(a,m);
if(rem(b,g))
  error('no solution to the congruence');
end
alpha = a/g;
beta = b/g;
mu = m/g;
[g1,alphabar,gamma] = gcdint2(alpha,mu);
x0 = mod(alphabar*beta,m);
x = mod(x0+(0:g-1)*mu,m);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?