2 ms·
> walk through a solution instead of stating "This algorithm self-evidently works" like a jerk. After every iteration, "result" gives correct remainders for al
by Joker_vD 5y ago
> walk through a solution instead of stating "This algorithm self-evidently works" like a jerk.
After every iteration, "result" gives correct remainders for all divisors considered so far, so if the loop ends, the "result" will give correct remainders for all divisors. The only problem is whether it will end or not, and that I just tried experimentally: it stopped, so ok. Not really sure how to explain it further.
> Also, the last modulo isn't needed.
Good to know, I was not sure if I wouldn't step past it due to constantly increasing addend. I knew about this modular reduction from that one time when I needed to align/move/scroll things on a 80x25 grid.