1

I took a test in number theory and modular arithmetic today, and one of the questions looked like this:

Two grasshoppers A and B hop in a circle that is divided into 81 squares. The squares are numbered from 0 to 80. Grasshopper A starts on square no. 5 and hops 15 squares clockwise with each jump. Grasshopper B starts on square no. 80 and jumps 14 squares anticlockwise with each jump. They always jump at the same time. After how many jumps do they bump into each other for the first time? (i.e. when are they on the same square for the first time)

I tried doing it like this:

Let the clockwise direction be positive, and let $0\le p\le 81$ denote the position of a grasshopper after $n$ moves. Then, the position of A and B can be found using: $\displaystyle 15n+5\equiv_{81}p_A$ and $\displaystyle 80-14n\equiv_{81}p_B$, respectively. Now, since we want their position to be the same, we have to find the smallest integer solution to the following congruence: $\displaystyle 15n+5\equiv_{81}80-14n$ which is equivalent to $29n \equiv_{81} 75 \equiv_{81} -6$.

This is where I did not get any further. I have no idea how to find $n$ (and using systematic testing gave 0 points). Apparently, my professor suggested rewriting it as a diophantine equation but that doesn't exactly seem easier. Any suggestion on how to solve for $n$ is greatly appreciated!

J. W. Tanner
  • 60,406
naytte2
  • 442
  • The next step involves multiplying both sides by the (multiplicative) inverse of $29 \bmod 81$. How to find that value is a basic exercise in number theory, involving the Euclidean algorithm. Does that agree with the topics you've studied? – hardmath Jan 31 '24 at 19:21
  • No, it does not sound familiar. The Euclidian algorithm is familiar, but I do not know what a multiplicative inverse is (or at least we have not used that term). – naytte2 Jan 31 '24 at 19:24
  • How about finding the greatest common divisor of $29$ and $81$? Are you familiar with using the Euclidean algorithm to find that? – hardmath Jan 31 '24 at 21:38
  • 1
    A previous Question here may help you understand the connection between the multiplicative inverse (Bezout identity) and "rewriting it as a diophantine equation" suggested by your professor. – hardmath Jan 31 '24 at 21:47
  • "Two grasshoppers A and B hop in a circle that is divided into 81 squares." How do you divide a circle into squares? – Gerry Myerson Feb 01 '24 at 02:39
  • @GerryMyerson I don't think the student is meant to interpret that literally, merely that there is a circle, on the circumference of which $81$ squares have been placed – H. sapiens rex Feb 01 '24 at 03:47
  • @H.s, whoever put that question together should have taken more care with the wording. In math, we don't have to say kinda sorta what we mean – we've developed the language to say exactly what we mean, and we should get that achievement across to our students. – Gerry Myerson Feb 01 '24 at 04:21
  • @GerryMyerson I understand that, but I doubt OP was the one who put that question together, so I just don't see the use in heckling them for it. And let's not kid ourselves; if OP were to express that sentiment to their teacher, all they'd likely get would be a flat stare and "you know what I meant, now go do your homework" – H. sapiens rex Feb 01 '24 at 04:29

1 Answers1

2

$5+15n\equiv -1-14n \mod(81) \Rightarrow 6+29n\equiv 0\mod(81) \Rightarrow 29n\equiv -6 \mod(81)$.

The inverse of $29$ modulo $81$ is $14$, so we have $n\equiv -84 \equiv 78 \mod(81)$.

Check: if $n=78$, then $5+15\cdot78 = 1175\equiv 41 \mod(81)$. Likewise, $-1-14\cdot78 = -1093 \equiv 41 \mod(78)$.

In conclusion, it takes $78$ jumps for grasshoppers A and B to bump into each other for the first time.

As noted in the comments, the key step was to find the multiplicative inverse of $29$ modulo $81$. This number, call it $x$, is such that $29x\equiv 1\mod(81)$. It can be found a variety of ways, the two most common being the Euclidean algorithm (already noted in the comments) and trial multiplication by each number from $1$ to $80$. Of course, trial multiplication works best when dealing with small moduli and in fact is often quicker than the Euclidean algorithm in such a case.