How does modulus of a smaller dividend and larger divisor work?

后端 未结 10 1261
误落风尘
误落风尘 2020-12-15 04:47
7 % 3 = 1 (remainder 1)

how does
3 % 7 (remainder ?)

work?

相关标签:
10条回答
  • 2020-12-15 05:06

    (7 * 0) + 3 = 3; therefore, the remainder is 3.

    0 讨论(0)
  • 2020-12-15 05:12
    • 7 divided by 3 is 2 with a remainder of 1

    • 3 divided by 7 is 0 with a remainder of 3

    0 讨论(0)
  • 2020-12-15 05:13

    For my brain to understand this kind of question, I'm always converting it to a real world object, for example if I convert your question 3 % 7. I'm going to represent the "3" as a 3-inch wide metal hole, then the "7" as a 7 inch metal screw. Can you insert the 7 inch metal screw to a 3 inch wide metal hole? Of course not, therefore the answer should be the 3-inch metal hole, it doesn't matter even let say you have a 1000 or a million inch wide screw, it is still 3, because how many times can you insert the 1000 or a million inch wide screw to a 3 inch wide metal hole? Zero times, right?

    0 讨论(0)
  • 2020-12-15 05:23

    Conceptually, I think of it this way. By definition, your dividend must be equal to (quotient * divisor) + modulus

    Or, solving for modulus: modulus = dividend - (quotient * divisor)

    Whenever the dividend is less than the divisor, the quotient is always zero which results in the modulus simply being equal to the dividend.

    To illustrate with OP's values:

    modulus of 3 and 7 = 3 - (0 * 7) = 3
    

    To illustrate with other values:

    1 % 3:
    1 - (0 * 3) = 1
    
    2 % 3:
    2 - (0 * 3) = 2
    
    0 讨论(0)
提交回复
热议问题