COMP-550-AlgorithmAnalysis icon indicating copy to clipboard operation
COMP-550-AlgorithmAnalysis copied to clipboard

Modified Code

Open GaryAvc opened this issue 5 years ago • 0 comments

you could modify this code by changing

modulos.add((int) (( modulos.get( i ) % m + modulos.get(i + 1) % m ) % m));

to

modulos.add((int) (( modulos.get( i ) + modulos.get(i + 1) ) % m));

it work correctly, since what you add before is the remainder of m, it have to be smaller than m So the step of modulos.get(i) %m is useless and meaningless, since modulos.get(i) always <=m which means modulos.get(i)%m equal to modulos.get(i)

GaryAvc avatar May 04 '20 13:05 GaryAvc