How Does Modulus Divison Work

后端 未结 19 2073
栀梦
栀梦 2020-11-22 06:55

I don\'t really understand how modulus division works. I was calculating 27 % 16 and wound up with 11 and I don\'t understand why.

I can\'t

19条回答
  •  被撕碎了的回忆
    2020-11-22 07:24

    I would like to add one more thing:

    it's easy to calculate modulo when dividend is greater/larger than divisor

    dividend = 5 divisor = 3

    5 % 3 = 2

    3)5(1
      3
    -----
      2
    

    but what if divisor is smaller than dividend

    dividend = 3 divisor = 5

    3 % 5 = 3 ?? how

    This is because, since 5 cannot divide 3 directly, modulo will be what dividend is

提交回复
热议问题