Least possible value for a modulo with given remainders

Hello guys. Im just asking how do you code a program that gets the LEAST value of a given modulo and remainder. Say example
Z = [3 4 5]
R = [2 1 4]
The inputs will give an output that gives the LEAST possible value for the given. So the answer to the above is 29.

3 comentarios

John D'Errico
John D'Errico el 8 de Dic. de 2015
Editada: John D'Errico el 8 de Dic. de 2015
In general, you would use the chinese remainder theorem for problems of this ilk. Your question is not terribly clear though. Are you asking to solve for x, such that
mod(x,[3 4 5]) == [2 1 4]
You code it by writing the code. You COULD use intlinprog. if you think about the meaning of those modular equations.
mod(x,3) == 2
is equivalent to
x == 3*u1 + 2
likewise for the others. Then can you solve for x,u1,u2,u3, such that x is minimized, is non-negative, AND is integer, along with u1,u2,u3?
help intlinprog
Umm since i am given 3 modulos with remainders, there are a lot of possible values for that. How do i get the least possible though?
I can input any values of the modulo and remainder. the above is just an example input.

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Preguntada:

el 8 de Dic. de 2015

Editada:

el 9 de Dic. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by