2 ms·
This can be seen as a "sped up" version of subtraction, since a%b = a-bk = a-b-b-...-b for some k. If you were doing it by hand you would always take (the larg
by edflsafoiewq 6y ago
This can be seen as a "sped up" version of subtraction, since a%b = a-bk = a-b-b-...-b for some k.
If you were doing it by hand you would always take (the larger)%(the smaller). You use modulo-then-swap instead, which is interesting. If a<b, then the modulo is wasted, but the swap ensures the next modulo won't be.