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.
Fast hardware implementation to calculate modulo 3? - repost
Whoa nelly.
Sorry about the deletion. I didn't think that the post was such a teaching moment.
No the original question was not for homework. I am out of school, despite what my questions may look like :) It actually came from a job interview I had just done and struggled with this as a question. The deletion came because I typically take notes in a text file locally, and pasted the reddit link in my notes to save. But when emailing the interviewer as a followup with notes, I pasted the reddit link in there as well in the body of the notes. I didn't want the interviewer to track down my post history using that link.
Anyway, sorry again. There was no ill intent in terms of "keeping information to myself". This repost should be fine as the original link doesn't point to it.
More on reddit.comMod 3 worth it?
XD Mod 3
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 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.