How much is 17 mod 3?
17 mod 3 equals 2 since dividing 17 by 3 gives a quotient of 5 and a remainder of 2. The remainder is the result of the modulus operation. In simpler terms, 17 mod 3 = 2.
How to calculate modulo division?
To calculate modulo division: subtract the divisor from the dividend until the resultant is less than the divisor.
What are the components of modulo division?
The components of modulo division are dividend, divisor, quotient, and remainder. The remainder is the answer or end result of the operation.
Videos
when we talk about mod and reminder, what exactly are the reminders here, for example 3mod4 and -1mod4 how come the reminder is 3? is it about how much it left to reach the next integer number bigger integer or what, cuz for example here 3mod4 here is 3 so it's like it left only 1 to reach the next bigger integer the same for -1mod4?
integer x ... -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 ...
mod x 3 ... 0 1 2 0 1 2 0 1 2 0 1 2 ...
The sequence above satisfies the equation mod (x+3) 3 = mod x 3 for any x. Note how 0 1 2 is continuously repeated.
Note that in Haskell we have both
mod (-4) 3 == 2
rem (-4) 3 == -1
where
integer x ... -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 ...
rem x 3 ... 0 -2 -1 0 -2 -1 0 1 2 0 1 2 ...
mod x y is the "remainder" of div x y where the division is rounded down (towards -infinity). Instead rem x y is the remainder of quot x y where the division is rounded towards zero (so the "remainder" can be negative).
It's the same as the mod of a positive number. In arithmetic modulo c, we seek to express any x as qc+r, where r must be a non-negative integer.
Why don't we test it out with an example?
Take −100 mod 8=4. This is because 8⋅−13=−104. The remainder is 4.
I'll try to explain...my way: the qc + r for a positive means that 100 mod 8 = 4 because you can express it as 8*12 + 4 meaning you can pull 12 8's out of it but you'll end of needing 4 in order to reach 100. In the negative case you can "pull out" -13 8's, then you'll need to ADD 4 (positive number) to reach 100.
So in your case you can pull out TWO 3's (ending at -6) then you'll need positive 2 left over to reach -4
might need a mathematician to explain: https://math.stackexchange.com/questions/519845/modulo-of-a-negative-number
In the below examples, the modulus with the positive integers makes sense. I've almost been programmed my whole life with division and remainders. However, the negative numbers don't make sense. I've looked at difference formulas, but I can't seem to make them work in my head or on paper. (Using the Window calculator for results)
-4 mod 3 = 2 but 4 mod 3 = 1 -5 mod 3 = 1 but 5 mod 3 = 2