Question
Give a bijection from $\Bbb N\to\omega^{\omega}$
Where $\omega^{\omega}$ is the set of ordinals expressible in Cantor normal form as:
$$\sum_{i=k}^0\omega^i\cdot a_i:a_i\in\Bbb N_{\geq0}$$
Attempt 1
A close try is to let $a_i$ count the number of consecutive ones and twos in an integer's binary representation:
$27=11011_2\mapsto\omega^2\cdot2+\omega+2$
But since there are no zero-length sequences of ones or twos in binary representations, this is unable to represent any ordinal having a finitely long sequence of consecutive zero coefficients.
Attempt 2
One might think of just reducing each coefficient by $1$ like this:
$27=11011_2\mapsto\omega^2+1$
This now represents zero coefficients, but it fails to inject because it gives the same ordinal $0$ for all the following numbers:
$S_n=1,2,5,10,21,42,85,\ldots$.
Attempt 3
Ideally I'd like to fix this approach rather than take a new approach altogether. I'm not sure how to proceed but I have a rough hunch we might be able to add or multiply a number (which may not truly be an ordinal) of the following form or similar:
$$\beta=\sum_{i=0}^\infty\omega^{2i+k}\cdot$$
but I'm all out of ideas really, beyond that.
(It will simplify things to replace the ordinal $\omega^\omega$ with the set $S$ of sequences of natural numbers which are cofinitely-often zero; talking about ordinals just makes things feel more mysterious than they actually are, in my experience. The point is that there is a bijection between $\omega^\omega$ and $S$ given by sending each $\alpha\in\omega^\omega$ to its sequence of coefficients in Cantor normal form, putting a "$0$" in the $i$th position when there is no $\omega^i$-term. So e.g. $$\omega^3\cdot2+\omega+3=\omega^3\cdot 2+\omega^2\cdot 0+\omega\cdot 1+\omega^0\cdot3$$ gives the sequence $\langle 3,1,0,2,0,0,0,0,...\rangle$.)
Since all but finitely many terms of an element of $S$ are zero, we can use prime factorization here: consider the map $$\mu: s\mapsto \prod p_i^{s(i)}$$ where $p_i$ denotes the $i$th prime and $s(i)$ denotes the $i$th term of $s$.
Since all but finitely many terms of each $s\in S$ are zero, $\mu$ is in fact a function from $S$ to $\mathbb{N}$, and subsequently by the fundamental theorem of arithmetic $\mu$ is a bijection.