Fixed points of sum of factorial of digits function

31 Views Asked by At

Let $f:\mathbb{Z}\rightarrow \mathbb{Z}$, $f:x=\sum_k x_k 10^k \mapsto \sum_k x_k!$ where $x_k$ is the $k$-th digit of $x$ in base ten. This function came up in a Project Euler problem. The question is which numbers are the sums of the factorials of their own digits, i.e. $x$ such that $f(x)=x$, i.e. the fixed points.

There are two nontrivial fixed points, 145 and 40585. I'm wondering if this can be shown without a brute force search. There is a cutoff since $f(x) < x$ when $x$ is greater than about 6 digits since $\sum_k x_k! < \sum_k 9! = N*9! < 10^N$ where $N$ is the number of digits.

A cursory search through a list of fixed point theorems didn't reveal one whose conditions $f$ meets. $f$ is not a contraction mapping nor monotonic. Iterating $f^k$ seems to converge to a handful of small cycles of order 3 or so.

Is there a fixed point theorem that applies to $f$?

2

There are 2 best solutions below

1
On

You can restrict the search range by thinking about what factorials are too large for a given number of digits. For example, for three digits you can't have any digit higher than $6$ and you can only have one of those. You need at least one $5$ or $6$ or you can't get to $100$. We are down to a couple hundred numbers to try. However, once you are down to a few million possibilities it is probably easier to turn on the brute search. It will run quickly so coding the restrictions will take longer than brute force.

1
On

An 8 digit number is at least 10,000,000. The sum of 8 factorials of digits is at most 8x9! = 2,903,040. So you have at most 7 digits, with the sum at most 7x9! = 2,540,160, so the first digit is 1 of 2 and there are at most six 9s, so the sum is at most 2! + 6x 9! = 2,177,282. That’s small enough for brute force.

You can also check 6, 5, 4, 3, 2, 1 digits in descending order and check that the sum has the same digits. Six digit numbers can be preceded by 1 or 2 adding 1! Or 2! to the sum.