4

I have posted this question originally in Stack Overflow.

The question is, "Is there a mathematical approach in getting the reverse of the Modulo Operator with given result $r$ and divisor $d$?"

So, the Modulo Operator % gives the remainder when dividing two numbers:

3 % 2 = 1

I will be asking the same question here.

Is there a mathematical approach in getting the reverse of the Modulo Operator with given result $r$ and divisor $d$?

NOTES: As I have stressed in the SO question, the answers should be limited to numbers which can be converted to a valid time in the format HHMMss.xxx where HH is the 24-hour respresention of hours, M is the minutes, s as seconds and x as millisecond. You need not worry about that part though because I can do a checking using Regex for that. You can check my updated question in SO.

xGeo
  • 143

1 Answers1

4

As pointed out in the comments and in the original Stack Overflow post, there are infinitely many numbers which divided by $\mathbf{d}$ have remainder $\mathbf{r}$. So there is a reverse operator given $d$ and $r$, but it will give you infinitely many solutions of the form $d\cdot k +r$.

F.A.
  • 1,001
  • I would like to point out that the answers, as I know that there could be multiple answers, should be less than 240000000. that will limit the "infinite" answers, right? Moreover, I would like to convert the numbers to a time format, so, [00 - 23][00-59][00-59]. But of course, you need not think about the time formatting. I can do that using code. – xGeo Mar 20 '18 at 16:54
  • 1
    @Geoman I guess you cold write a $while$ loop and make one of the conditions be $d\cdot k + r < 240000000$ while you keep increasing $k$. – F.A. Mar 20 '18 at 17:47
  • And yes, then there would be a finite number of answers – F.A. Mar 20 '18 at 17:57
  • nice suggestion @F.A. I think that will be faster. Thanks! – xGeo Mar 20 '18 at 19:14