1

How do I multiply out modular division(s) to simplify for x? I am trying to tackle a coding problem and I'm hopeful that I can simplify the equation in terms of $x$ ($x = ???$) from the following statement: $$b\mod{x} = x \mod{a}$$

Example: $x=6$ where $a = 6$ and $b = 36 $: $$36\mod{6} = 6 \mod{6} = 0$$

All possible values for $a$, $b$, and $x$ are integers that are $\geq 1$ and $\leq 100$. Any steps that can help would be appreciated!

  • Hi C. I am having trouble to understand your scenario. For example, what exactly does $b\mod{x} = x \mod{a}$ mean? – 311411 Dec 09 '21 at 16:48
  • 2
    I believe this is the computer scientist's use of modulus: the remainder when $b$ is divided by $x$ is the same as the remainder when $x$ is divided by $a$. Is this correct? – TomKern Dec 09 '21 at 16:51
  • @TomKern that is correct – Colin Lightfoot Dec 09 '21 at 17:00
  • 3
    Your question is not clear. Trusting that you are defining $n\pmod m$ as the remainder on dividing $n$ by $m$, then $x$ is not uniquely determined by your equality. And what do you mean by "asymptotic" in this context? – lulu Dec 09 '21 at 17:00
  • 1
    Do you have any restrictions on $a$, $b$, or $x$? They're rational, integers, something else? They're nonnegative, positive, something else? – Eric Towers Dec 09 '21 at 17:02
  • 2
    @TomKern The $!\bmod$ operation is also used by mathematicians - see here for more. – Bill Dubuque Dec 09 '21 at 17:03
  • 2
    Perhaps it would clarify things if you edited your post to include a clear, fully worked, numerical example of the sort of computation you are interested in. – lulu Dec 09 '21 at 17:03
  • @EricTowers the constraints are that $x$, $a$, and $b$ are all integers greater than or equal to 1 and less than or equal to 100 – Colin Lightfoot Dec 09 '21 at 17:04
  • 1
    So ... an answer is write a small program that, for each $a$ in that range, for each $b$ in that range, for each $x$ in that range, write down the $(a,b,x)$ triples that satisfy the equation you give, then wrap that list in a function that does a lookup in a list indexed by the first two entries of each triple to get the third entry? – Eric Towers Dec 09 '21 at 17:07
  • @EricTowers yes that could work - I was just hoping that there was an easier way via simplyfing the above statement somehow. lulu, I removed the asymptotic comment as it wasn't relevant. – Colin Lightfoot Dec 09 '21 at 17:09
  • 1
    Nonuniqueness immediately appears when you do that: The triples $(a,b,x) \in {(1,4,1),(1,4,2),(1,4,4)}$ ensure that you do not have only one choice of $x$ for a given $a$ and $b$. – Eric Towers Dec 09 '21 at 17:11
  • 1
    In many computer languages, "the reduction of $a$ modulo $b$", meaning the remainder after integer-dividing $a$ by $b$, is denoted $a% b$, to distinguish it from "$a$ mod $b$"... although this still conflicts with other uses of the percent sign $%$ – paul garrett Dec 09 '21 at 17:11
  • 1
    Even your $b=36, a=6$ example has seven solutions $x \in {6,7,12,16,18,33,36}$. – Eric Towers Dec 09 '21 at 17:16
  • 1
    The reduces your example to four solutions: 6, 12, 18, and 36. This of course, tells you how to find the $x$s. – Eric Towers Dec 09 '21 at 17:25
  • @EricTowers, I see now that my verbage was incorrect. Instead of "solve for $x$", I meant to "simplify in the statement in terms of $x$". As in $x = ???$. – Colin Lightfoot Dec 09 '21 at 17:26
  • 1
    Yes. The conditions are insufficient to reduce to a single $x$. There are four $x$s that satisfy your example. I've listed them. Try each of them if you are unsure. – Eric Towers Dec 09 '21 at 17:27
  • Thank you @EricTowers! I understand how you reached those values. I was just hoping there was a way to simplify the equation into terms of $x$. Thank you for showing me that is not possible. – Colin Lightfoot Dec 09 '21 at 17:29
  • 1
    In fact, every $x$ such that the remainder on dividing $b$ by $x$ is zero are the divisors of $b$. Likewise, the $x$ such that the remainder on dividing $x$ by $a$ is zero are the multiples of $a$. So you want a multiple of $a$, less than $100$ that also divides $b$. There need not even be such a number. Take $a = 2$, $b =3$. No multiple of $a$ (so, even numbers) divides $b$. – Eric Towers Dec 09 '21 at 17:32

0 Answers0