Over on Code Golf.SE, I've asked this challenge about the looping behaviour of a function related to narcissistic numbers. In the question, I define the function as, for a natural number $x = d_1d_2...d_n$ where $d_i$ is a single digit between $0$ and $9$ and $x$ has $n$ digits:
$$f(x) = \sum_{i=1}^n d_i^n$$
In this case, a number is narcissistic if it is a fixed point of $f(x)$ i.e. $f(x) = x$. However, the question is about repeated application of this function. For example, repeatedly applying $f$ to $x = 127$ leads to the following chain of numbers:
$$127,352,160,217,352,160,217,...$$
and the triplet $352, 160, 217$ repeats ad infinitum from here. I have two hypotheses which I believe to be correct but have no idea how to prove:
- For all natural numbers $x > 0$, repeated application of $f$ eventually leads to a repeating loop (counting a fixed point as a "loop" of 1 element).
- The length of this loop is always less than or equal to $14$. For example, $x = 147$ is the lowest number that yields $14$, with a loop of
$$537059, 681069, 886898, 1626673, 1665667, 2021413, 18829, 124618, 312962, 578955, 958109, 1340652, 376761, 329340$$
My brute forcing attempts have shown that this is true for all $x < 10^5$, and is currently (at time or writing) at around $x = 64000$ without having found a counter example to either hypothesis.
This is a program which takes an input $x$ and outputs the repeated application of $f$ to $x$ until a repeated value is found, the loop of $x$ and the length of said loop, if you'd like to test out some other numbers.