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 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 have the solution to this problem, but I don't understand the logic behind the solution.
Mod 3 worth it?
XD Mod 3
Why does (-1) % 3 = -1 ?
Because modulo operations aren't consistent across all programming languages. Some use floored division in the calculation, others use truncated. Floored division would yield a - b(floor(a/b)) where the floor is done towards the lowest number. So -1 - 3*(floor(-1/3)) would simplify to -1 - 3*-1 which would provide an answer of 2.
GML uses truncated division for modulo ops, where it rounds off any remainder but does so towards 0. So this means you get -3*0 in this instance which results in just -1 being left.
More on reddit.comHow 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 is a modulo operator?
The modulo operator is used to find the remainder during a division of two numbers. The operator is represented by the symbol % in most programming languages. It is also known as the remainder operator. As an example, 5 mod 2 returns 1.
Videos
This is the problem, and this is the solution.
Already, on the first sentence I have a question. They just multiplied the end points of the range of integers the question asked us to consider by 3 and just said that would give us the same answer. I don't understand how those things are the same, nor do I understand why they multiplied by three specifically.
Then, they take the mod 3 of all the numbers the digits could be. They take 9 mod 3 and 3 mod 3. They get 0 for both, makes sense. 1 mod 3 and 7 mod 3 are 1, makes sense. But they take 5 mod 3 and get -1? What? Wouldn't it be 2? It is my understanding that mod is never negative.
Also, why take the mod 3 of the possible digits? How did that help? I assume it's somehow connected with the fact that a number divisible by 3 has the sum of its digits divisibly by three, but I don't see the connection.
Then, they use the modulus in a completely unclear way, at least to me. So, the first bullet point states that the amount of numbers that start with 3 followed by three digits that have a modulus of zero is the same as 2 * 2 * 2. I don't know how having the first digit be 3 followed by three numbers that divide evenly into 3 result in 23.
Similarly, the second bullet point states the amount of numbers that start with 3 and are followed by "one [0], one [1], and one [-1]" results in 3! * 2 * 2 * 1. I have no clue how they got that.
I have the same question for all the bullet points. How did the initial statement after the bullet point lead to the following statement after the dash.