# Multiplicity of digits resulting from $9999[…]9^2$

Define the function $F(N) = (9[N])^2$, meaning: the number made of $N$ consecutive $9$'s digits, raised to the power $2$. For example, $F(4) = 9999^2$.

Looking at some example values, it seems like there are only $4$ possible digits in the resulting number: $0,1,8,9$.

Can you give me an expression for the multiplicities of each of these digits, as a function of N? For example, $F(4) = 999^2 = 998001$, which has two $0$'s, one $1$, one $8$, and two $9$'s.

Also, it seems like (again, only testing on some small values of $N$), a given digit will have all of its occurrences consecutively, e.g. for $F(7)=9999999^2$, the result is $99999980000001$, which has all of the $9$'s consecutively, and all of the $0$'s consecutively. Is this true in general for any non-negative integer $N$ that the digits will have this consecutive property?

$$(10^N-1)^2 = 10^{2N} - 2 \cdot 10^N + 1 = \sum_{j=N+1}^{2N-1} 9 \cdot 10^j + 8 \cdot 10^N + 1$$ so there are $N-1$ 9's, followed by $8$, $N-1$ 0's and finally $1$.