MHB Is It Possible to Find a Mod m and a Div m for Given Values of a and m?

  • Thread starter Thread starter shamieh
  • Start date Start date
shamieh
Messages
538
Reaction score
0
Find a div m and a mod m when

$a = -111$, $m = 99$

so I got the first one:
$a =-2*99+87$ => amodm=87 and adivm = -2

so if I had $a=−9999$ and $m = 101$ would that mean that $a = −2∗101-9797$ ? so a mod m $= -9797$ and a div m =$ -2$ ?

or should it be $a =-1 *101 + -9898$ => amodm = $-9898$ and adivm = $-1$
 
Last edited:
Physics news on Phys.org
The remainder (mod) is always between $0$ and $m - 1$ inclusive (for positive $m$), that's how the quotient is unique.
 
Bacterius said:
The remainder (mod) is always between $0$ and $m - 1$ inclusive (for positive $m$), that's how the quotient is unique.

so the remainder mod, in this case is between $0$ and $100$ right (101-1)? This fact still doesn't answer my question though. I need to know if my method is correct or incorrect.
 
shamieh said:
so the remainder mod, in this case is between $0$ and $100$ right (101-1)? This fact still doesn't answer my question though. I need to know if my method is correct or incorrect.

Yes, and it does, your method is incorrect, for the remainder you found in the second case isn't in this interval and so is wrong.

In theory, to find the quotient and remainder for positive $m$ what you do is find the smallest nonnegative integer $r$ such that $a - r$ is a multiple of $m$ ($r$ will be the remainder) and then divide $a - r$ by $m$ to find $q$. In practice you usually want to find the quotient first by dividing $a$ by $m$ and rounding down, and then working out the remainder from that.

For instance with $a = -111$ and $m = 99$, you compute $a / m \approx -1.12$, which when rounded down gives $q= -2$, so that you have $a = qm + r$, that is, $-111 = (-2) 99 + r$, so $r = -111 - (-2)99 = 87$.

For $a = -9999$ and $m = 101$ we get $a / m = -99$ (it happens to be exact), so there's no need to round down and so $q = -99$, and we get $-9999 = (-99)101 + r$, so $r = -9999 - (-99)101 = 0$ (in fact you already knew the remainder was zero, since $101$ happened to divide $-9999$ as the division gave an integer).
 
Thank you for the help bacterius. This is going to sound like a really dumb question but you are saying that I need to round down $-1.12$ to $-2$ ... How in the world does $-1.12$ round down to $-2$ ?
 
OH! Bacterius I'm an idiot. I see what you are talking about. $\lfloor -1.12 \rfloor = -2$
 
Namaste & G'day Postulate: A strongly-knit team wins on average over a less knit one Fundamentals: - Two teams face off with 4 players each - A polo team consists of players that each have assigned to them a measure of their ability (called a "Handicap" - 10 is highest, -2 lowest) I attempted to measure close-knitness of a team in terms of standard deviation (SD) of handicaps of the players. Failure: It turns out that, more often than, a team with a higher SD wins. In my language, that...
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...

Similar threads

Back
Top