Search code examples
modulo

How does 3 modulo 7 = 3?


I was wondering how modulo works. I know how it works when the bigger number comes first, but not the opposite. I know that 7 % 3 = 1 as 3 goes up to 7 2 times and the remaining is 1. However, when it's 3 % 7. I have used the calculator it shows 3. Is this because 7 goes up to 3 zero times and the remaining is 3? Is that how it works?


Solution

  • Your reasoning is correct. Any time the divisor is larger than the dividend, the result of the modulo operation equals the dividend.