TITLE: Does the set of happy numbers have a limiting density?
QUESTION [20 upvotes]: A positive integer $n$ is said to be happy if the sequence
$$n, s(n), s(s(n)), s(s(s(n))), \ldots$$
eventually reaches 1, where $s(n)$ denotes the sum of the squared digits of $n$.
For example, 7 is happy because the orbit of 7 under this mapping reaches 1.
$$7 \to 49 \to 97 \to 130 \to 10 \to 1$$
But 4 is not happy, because the orbit of 4 is an infinite loop that does not contain 1.
$$4 \to 16 \to 37 \to 58 \to 89 \to 145 \to 42 \to 20 \to 4 \to \ldots$$
I have tabulated the happy numbers up to $10^{10000}$, and it appears that they have a limiting density, although the rate of convergence is slow. Is it known if the happy numbers do in fact have a limiting density? In other words, does $\lim_{n\to\infty} h(n)/n$ exist, where $h(n)$ denotes the number of happy numbers less than $n$?

REPLY [8 votes]: I started working on this question after it was posted to MathOverflow and found bounds similar to those found by Justin Gilmer: upper asymptotic density of the happy numbers 0.1962 or greater, lower asymptotic density no more than 0.1217.  However, I was also able to prove that the upper asymptotic density of the happy numbers was no more than 0.38; Gilmer mentioned in his paper that the question of whether the upper asymptotic density was less than 1 was still open.
A writeup of the result is at http://djm.cc/dmoews/happy.zip.  The method used to find an upper bound on the upper asymptotic density was to start with a random number with decimal expansion  $??\dots{}??\hbox{\#}\hbox{\#}\dots{}\hbox{\#}\hbox{\#}$, where the digits # are independent and uniformly distributed, and the digits ? are arbitrarily distributed and may depend on each other, but are independent of the #s.  Then if there are $n$ #s, asymptotic normality implies that after applying $s$, we get a mixture of translates of a distribution which is approximately
normal, with mean $28.5n$ and standard deviation proportional
to $\sqrt{n}$.  If $10^{n'}/\sqrt{n}$ is sufficiently small, each translate
of this normal distribution will have its last $n'$ digits approximately
uniformly distributed, so we get a random number which can be approximated by the same form of decimal expansion we started with, $??\dots{}??\hbox{\#}\hbox{\#}\dots{}\hbox{\#}\hbox{\#}$, where now there are $n'$ digits #.  Repeating this eventually brings us to numbers small enough to fit on a computer.
The method used to find the bounds similar to Gilmer's was to start with a random number of the form  $dd\dots{}dd??\dots{}??\hbox{\#}\hbox{\#}\dots{}\hbox{\#}\hbox{\#}$, where the ?s and #s are as before, the $d$s are fixed digits, and there are the same number of $d$s and #s, but very few ?s.  Then if the parameters are appropriately chosen, we can show that after applying $s$, we again get a random number which can be approximated by the same form of decimal expansion, $dd\dots{}dd??\dots{}??\hbox{\#}\hbox{\#}\dots{}\hbox{\#}\hbox{\#}$, and repeat this step until the number is small.