# Functional Square Root of Digit Sum?

Define $\text{sdig}(n)$ to be the sum of the decimal digits of $n$, where $n$ is a positive integer. My question is as follows:

Does there exist a function $h:\mathbb Z^+\mapsto\mathbb Z^+$ such that $$(h\circ h)(n)=\text{sdig}(n)$$ for all $n\in\mathbb Z^+$? That is, does there exist a functional square root of the digit sum function?

So far, this problem has stumped me. I've shown that if such $h$ exists, it must commute with the digit sum function. I've also shown that if $S_a$ is the set of numbers whose digit sum is $a$, then for all $a$, there exists some $b$ such that the function $h$ maps all elements of $S_a$ to elements of $S_b$. However, whether these discoveries lead to the construction of such a function or the proof of its nonexistence I do not know.

Any ideas?

I think you can by building $h(n)$ up by digit sums. It seems natural to set $h(n)=n$ for $n \lt 10$. Now you can let $h(n)=\operatorname{sdig}(n)$ if $10 \le 10\le 18$. Then we can let $h(n)=\operatorname{sdig}(n)+9$ if $\operatorname{sdig}(n)\le 9$ The first value we have not yet accounted for is $h(19)$. If $h(19)=a,$ we need $h(a)=10$ and then we need $h(h(a))=1$, so we pick a convenient $a$ like $100$ and set $h(19)=100$. Now we can set $h(n)=100$ if $\operatorname{sdig}(n) = 10$. The next one we need to handle is $h(29)$. Again, if $h(29)=b,$ we need $h(b)=11$ and $h(h(b))=2$, so $\operatorname{sdig}(b)=2$. We can set $h(n)=101$ if $\operatorname{sdig}(n) = 11$. I think you can just keep building up $h(n)$ from the digit sums this way. We have two tables $$\begin {array} {r |r}n&h(n)\\ \hline 1-9&n\\10-18&n-9 \end {array}$$
$$\begin {array} {r |r}\operatorname{sdig}(n)&h(n)\\ \hline 1-9&\operatorname{sdig}(n) \\10-19&\operatorname{sdig}(n)+90 \\20-99&\operatorname{sdig}(n)+900 \end {array}$$ Now if we have a number $k$ with sum of digits $19$ we need $h(h(k))=19$ and $h(k)$ needs a digit sum of $10$. $109$ works well and we can extend the bottom row of the table to cover $\operatorname{sdig}(n)$ of $19$. Because $h(20)=11$ wherever we send digit sums of $20$ has to have a digit sum of $11$. $920$ looks like a nice number and we can add a line to the table. For a sum of digits of $30$ we have $h(30)=12$ so we need to send it somewhere that has a sum of digits of $12$. We observe that we can extend the bottom line to cover digit sums up to $99$. It seems clear we can keep going.