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
Hint divides one of
so
Remark Said modly,
If is not a multiple of
, either one of these must hold:
or
Basically, those are saying that the remainder on dividing by
is either
or
.
Now, the second can also be expressed as
So everything can be more concisely expressed as ,
allowing us to square easily giving: .
The remainder in 1%3 refers to what remains of 1 (not 3) after you divide by 3. As you have already said, 3 goes into 1 zero times. So -- when you remove 0 multiples of 3 from 1, all of 1 remains. Thus 1 % 3 = 1.
The result of a modulo operation n % m is just that number r for which q * m + r = n (q may be anything). The only requirement we have is that 0 <= r < m.
So for instance:
7 % 5 --> 1 * 5 + 2 == 7 --> r = 2
1 % 3 --> 0 * 3 + 1 == 1 --> r = 1
I come from a computer science background and my mind is exploding rn from this.
In programming languages the % represents the modulo operation.
In most programming languages like C, Rust, Java, JavaScript -7 % 3 results in -1, this makes sense to me logically since if I have "negative 7 dollars" divided it across three people, each will get "-2 negative dollars" and "-1 negative dollar" will remain.
So how come in any calculators, and the few mathematics-friendly programming languages like Python and Haskell, -7 % 3 results in 2? Like logically speaking how could dividing a negative number result in a positive number, and where did the 2 even came from, from a logical standpoint?