About an odd constant in a longest arrangement problem

64 Views Asked by At

In my previous question about the longest chain of $n$-digit square numbers where last digit equal the first digit of next, the nice solution given by Misha Lavrov took me to consider the ratio of the maximum number of squares in a chain and the number of total squares with $ n $ digits and as $ n $ gets bigger, it approaches the constant $$ 0.417069122... $$ Do you know a closed form for that?

1

There are 1 best solutions below

0
On BEST ANSWER

The closed form is $$\frac{1}{30} \left(\sqrt{10}+1\right) \left(\sqrt{2}+3 \sqrt{5}-3 \sqrt{6}+4 \sqrt{7}+4 \sqrt{10}-21\right) \approx 0.417069\dots$$

The solution works by constructing a directed graph with vertices $\{1,4,5,6,9\}$, where the number of edges from $a$ to $b$ is the number of perfect squares starting with $a$ and ending with $b$. Then, we construct an Eulerian subgraph for this graph by:

  • Reducing the outdegree of vertices $1$ and $5$ to the indegree;
  • Reducing the indegree of vertices $4$, $6$, and $9$ to the outdegree.

Therefore the number of edges is equal to the indegrees of $1$ and $5$ plus the outdegrees of $4$, $6$, and $9$. Up to lower-order terms, that's also the length of the sequence we get at the end.

To find these, the estimates we use are that

  • A $\frac{\sqrt{a+1} - \sqrt a}{\sqrt{10}-\sqrt 1}$ fraction of all perfect squares begin with the digit $a$;
  • The fraction of squares ending in the digit $b$ is $\frac1{10}$ for $b=0,5$ and $\frac2{10}$ for $b=1,4,6,9$;
  • The first and last digits are asymptotically independent.

Therefore the fraction of squares starting with $1,4,5,6,9$ and ending with $1$ or $5$ is $$\frac{(\sqrt2 - \sqrt1) + (\sqrt7 - \sqrt4) + (\sqrt{10}-\sqrt9)}{\sqrt{10}-\sqrt1} \cdot \frac{3}{10}$$ and the fraction of squares starting with $4,6,9$ and ending with $1,4,5,6,9$ is $$\frac{(\sqrt5 - \sqrt4) + (\sqrt7-\sqrt6) + (\sqrt{10}-\sqrt9)}{\sqrt{10}-1} \cdot \frac{9}{10}.$$ Adding these together gives the final answer above.