How to find the smallest possible value in Matlab, given the modulo values and its residual values in the array? eg:
A=[ 23 90 56 36] %
B=[ 1 3 37 21] %
which leads to an answer 93; which is the smallest possible value.
EDIT:
Here is my code, but it only seems that the last value of the residual array is the smallest value:
z = input('z=');
r = input('r=');
c = 0;
m = max(z);
[x, y] = find(z == m);
r = r(y);
f = find(z);
q = max(f);
p = z(1:q);
n = m * c + r;
if (mod(n, p) == r)
c = c + 1;
end
fprintf('The lowest value is %0.f\n', n)
source
share