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

  • MHB
  • Thread starter shamieh
  • Start date
In summary, for any given values of $a$ and $m$, to find the quotient and remainder we first divide $a$ by $m$ and round down to find the quotient $q$. Then, we use the formula $a = qm + r$ to find the remainder $r$, where $r$ is the smallest nonnegative integer such that $a - r$ is a multiple of $m$. In the case of $a = -111$ and $m = 99$, the quotient is $-2$ and the remainder is $87$. In the case of $a = -9999$ and $m = 101$, the quotient is $-99$ and the remainder is $0$.
  • #1
shamieh
539
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
  • #2
The remainder (mod) is always between $0$ and $m - 1$ inclusive (for positive $m$), that's how the quotient is unique.
 
  • #3
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.
 
  • #4
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).
 
  • #5
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$ ?
 
  • #6
OH! Bacterius I'm an idiot. I see what you are talking about. $\lfloor -1.12 \rfloor = -2$
 

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

What is the purpose of finding a mod m and a div m?

The purpose of finding a mod m and a div m is to perform modular arithmetic. This is useful in many fields of science, including cryptography, computer science, and physics.

What does "mod" mean in this context?

"Mod" is short for "modulo," which is a mathematical operation that finds the remainder after division. In this context, it refers to the remainder when a number is divided by another number.

What is the difference between mod m and div m?

Mod m and div m are two different operations. Mod m calculates the remainder after division, while div m calculates the quotient (the result of division). In other words, mod m finds the "leftover" and div m finds the "number of groups."

How do I find a mod m and a div m?

To find a mod m and a div m, you can use a calculator or perform the calculation manually. To find a mod m, divide the first number by the second number and take the remainder. To find a div m, divide the first number by the second number and take the quotient.

What are the applications of finding a mod m and a div m?

Modular arithmetic has many real-world applications. It can be used in computer algorithms, in cryptography to encrypt and decrypt messages, and in physics to calculate periodic phenomena. It is also used in number theory and abstract algebra.

Similar threads

Replies
1
Views
1K
Replies
1
Views
1K
Replies
2
Views
1K
Replies
1
Views
1K
Replies
2
Views
256
Back
Top