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
AI Thread Summary
The discussion centers on finding the quotient and remainder (div m and mod m) for given values of a and m. The correct method involves dividing a by m, rounding down to find the quotient, and then calculating the remainder. For example, with a = -111 and m = 99, the calculations yield a div m of -2 and a mod m of 87. In the case of a = -9999 and m = 101, the division is exact, resulting in a div m of -99 and a mod m of 0. The importance of ensuring the remainder is within the correct range (0 to m-1) is emphasized for accuracy.
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$
 
I'm taking a look at intuitionistic propositional logic (IPL). Basically it exclude Double Negation Elimination (DNE) from the set of axiom schemas replacing it with Ex falso quodlibet: ⊥ → p for any proposition p (including both atomic and composite propositions). In IPL, for instance, the Law of Excluded Middle (LEM) p ∨ ¬p is no longer a theorem. My question: aside from the logic formal perspective, is IPL supposed to model/address some specific "kind of world" ? Thanks.
Hello, I'm joining this forum to ask two questions which have nagged me for some time. They both are presumed obvious, yet don't make sense to me. Nobody will explain their positions, which is...uh...aka science. I also have a thread for the other question. But this one involves probability, known as the Monty Hall Problem. Please see any number of YouTube videos on this for an explanation, I'll leave it to them to explain it. I question the predicate of all those who answer this...
I was reading a Bachelor thesis on Peano Arithmetic (PA). PA has the following axioms (not including the induction schema): $$\begin{align} & (A1) ~~~~ \forall x \neg (x + 1 = 0) \nonumber \\ & (A2) ~~~~ \forall xy (x + 1 =y + 1 \to x = y) \nonumber \\ & (A3) ~~~~ \forall x (x + 0 = x) \nonumber \\ & (A4) ~~~~ \forall xy (x + (y +1) = (x + y ) + 1) \nonumber \\ & (A5) ~~~~ \forall x (x \cdot 0 = 0) \nonumber \\ & (A6) ~~~~ \forall xy (x \cdot (y + 1) = (x \cdot y) + x) \nonumber...

Similar threads

Back
Top