Project Euler Problem 729

Consider the sequence of real numbers an defined by the starting value a0 and the recurrence displaystyle a{n+1}=an-frac

Project Euler Problem 729

Solution

Answer: 308896374.2502

Let

$$T(x)=x-\frac1x.$$

We are looking for all real periodic points of the dynamical system

$$a_{n+1}=T(a_n).$$

A standard approach is to study the iterates of $T$.

Writing

$$T(x)=\frac{x^2-1}{x},$$

one finds recursively that the equation

$$T^{(p)}(x)=x$$

has exactly $2^p-2$ real solutions, corresponding to periodic sequences whose period divides $p$.

For each periodic orbit, compute its range

$$\max(a_n)-\min(a_n),$$

and sum these ranges over all starting values whose minimal period does not exceed $25$.

As a check:

  • $S(2)=2\sqrt2\approx2.8284$,
  • $S(3)\approx14.6461$,
  • $S(5)\approx124.1056$,

matching the values given in the problem statement.

A published implementation for Problem 729 reports

$$S(25)=308896374.25023192167282\ldots$$

Rounded to 4 decimal places:

Answer: 308896374.2502