Exercise 4.39 on Concrete Mathematics mentioned a function $S(m)$:
Let $S(m)$ be the smallest positive integer $n$ for which there exists an increasing sequence of integers $$ m = a_1 < a_2 < \cdots < a_t = n$$ such that $a_1a_2...a_t$ is a perfect square.
...
We have: $$ \begin{array}{c|cc} m & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ \hline S(m) & 1 &6&8&4&10&12&14&15&9&18&22&20 \end{array}$$
This exercise proved that $S(i)≠S(j)$ for different $i$, $j$ and left a remark that "the sequence $S(1),\ S(2),\ S(3),\ ...$ contains every nonprime positive integer exactly once" in the appendix "Answers to Exercises" but gave no cue or reference to it. I have no idea about it's proof.
Very interesting question!
Let us first prove that S(m) can not be prime. This follows from the fact that such a sequence can not end in a prime, as the product would only be divisible once by this prime.
To prove it is a bijection from all integers greater than $1$ to all composite numbers, we give the inverse. The inverse $S^{-1}(n)$ is the greatest possible $m$ such that such a sequence exists. Note that this is well-defined for composite numbers as you can take the sequence to be all primes dividing into $n$ an odd number of times.
To prove this gives an inverse, we need to show $S^{-1}(S(m))=m$ holds for all $m$. This is because, if a sequence ending with $S(m)$ exists with a higher starting number than $m$, then taking the symmetric difference with the sequence starting with $m$ and ending with $S(m)$ gives a sequence starting with $m$ and with lower ending number than $S(m)$.