The algorithm to compute the path to a particular pair of integers (m, n) is rather simple:

 

 

Begin with a pair of integers (m,n) and let S = ‘ ‘ be the empty string

 

If m < n set n to be n-m and add L on to the end of S (S↪SLS↪SL)

 

If m > n, set m to be m-n and add R on to the end of S (S↪SRS↪SR)

 

If m = n, the process stops and the path S is found

 

Until this happens, repeat step 2 or 3 depending on the condition