## Relating integers by differences of reciprocals

Let’s say that two positive integers m, n are compatible if the difference of their reciprocal is the reciprocal of an integer: that is, mn/(m-n) is an integer. For example, 2 is compatible with 1, 3, 4, and 6 but not with 5. Compatibility is a symmetric relation, which we’ll denote ${m\sim n}$ even though it’s not an equivalence. Here is a chart of this relation, with red dots indicating compatibility. Compatibility of integers up to 200

### Extremes

A few natural questions arise, for any given ${n}$:

1. What is the greatest number compatible with ${n}$?
2. What is the smallest number compatible with ${n}$?
3. How many numbers are compatible with ${n}$?

Before answering them, let’s observe that ${m\sim n}$ if and only if ${|m-n|}$ is a product of two divisors of ${n}$. Indeed, for ${mn/(m-n)}$ to be an integer, we must be able to write ${|n-m|}$ as the product of a divisor of ${m}$ and a divisor of ${n}$. But a common divisor of ${m}$ and ${m-n}$ is also a divisor of ${n}$.

Of course, “a product of two divisors of ${n}$” is the same as “a divisor of ${n^2}$“. But it’s sometimes easier to think in terms of the former.

Question 1 is now easy to answer: the greatest number compatible with ${n}$ is ${n+n^2 = n(n+1)}$.

But there is no such an easy answer to Questions 2 and 3, because of the possibility of overshooting into negative when subtracting a divisor of ${n^2}$ from ${n}$. The answer to Question 2 is ${n-d}$ where ${d}$ is the greatest divisor of ${n^2}$ than is less than ${n}$. This is the OEIS sequence A063428, pictured below. The smallest compatible number for n

The lines are numbers with few divisors: for a prime p, the smallest compatible number is p-1, while for 2p it is p, etc.

The answer to Question 3 is: the number of distinct divisors of ${n^2}$, plus the number of such divisors that are less than ${n}$. This is the OEIS sequence A146564.

### Chains

Since consecutive integers are compatible, every number ${n}$ is a part of a compatible chain ${1\sim \cdots\sim n}$. How to build a short chain like this?

Strategy A: starting with ${n}$, take the smallest integer compatible with the previous one. This is sure to reach 1. But in general, this greedy algorithm is not optimal. For n=22 it yields 22, 11, 10, 5, 4, 2, 1 but there is a shorter chain: 22, 18, 6, 2, 1.

Strategy B: starting with ${1}$, write the greatest integer compatible with the previous one (which is ${k(k+1)}$ by the above). This initially results in the OEIS sequence A007018: 1, 2, 6, 42, 1806, … which is notable, among other things, for giving a constructive proof of the infinitude of primes, even with a (very weak) lower density bound. Eventually we have to stop adding ${k^2}$ to ${k}$ every time; so instead add the greatest divisor of ${k^2}$ such that the sum does not exceed ${n}$. For 22, this yields the optimal chain 1, 2, 6, 18, 22 stated above. But for 20 strategy B yields 1, 2, 6, 18, 20 while the shortest chain is 1, 2, 4, 20. Being greedy is not optimal, in either up or down direction.

Strategy C is not optimal either, but it is explicit and provides a simple upper bound on the length of a shortest chain. It uses the expansion of n in the factorial number system which is the sum of factorials k! with coefficients less than k. For example ${67 = 2\cdot 4! + 3\cdot 3! + 0\cdot 2! + 1\cdot 1!}$, so its factorial representation is 2301.

If n is written as abcd in the factorial system, then the following is a compatible chain leading to n (possibly with repetitions), as is easy to check:

1, 10, 100, 1000, 1000, a000, ab00, abc0, abcd

In the example with 67, this chain is

1, 10, 100, 1000, 2000, 2300, 2300, 2301

in factorial notation, which converts to decimals as

1, 2, 6, 24, 48, 66, 66, 67

The repeated 66 (due to 0 in 2301) should be removed.

Thus, for an even number s, there is a chain of length at most s leading to any integer that is less than (s/2+1)!.

As a consequence, the smallest possible length of chain leading to n is ${O(\log n/\log \log n)}$. Is this the best possible O-estimate?

All of the strategies described above produce monotone chains, but the shortest chain is generally not monotone. For example, 17 can be reached by the non-monotone chain 1, 2, 6, 18, 17 of length 5 but any monotone chain will have length at least 6.

The smallest-chain-length sequence is 1, 2, 3, 3, 4, 3, 4, 4, 4, 4, 5, 4, 5, 5, 4, 5, 5, 4, 5, 4, 5, 5, 5, 4, 5, … which is not in OEIS.  Here is its plot: Smallest chain length for integers from 1 to 1000

The sequence 1, 2, 3, 5, 11, 29, 67, 283, 2467,… lists the smallest numbers that require a chain of given length — for example, 11 is the first number that requires a chain of length 5, etc. Not in OEIS; the rate of growth is unclear.