TITLE: Find a sequence with an interesting property
QUESTION [6 upvotes]: I was reading an Elon Lages Lima's book ("Curso de Análise", IMPA) and there is an interesting question. Find a function $f$ from $\mathbb N$ onto $\mathbb N$ such that $\forall n\in \mathbb N$, the preimage set $f^{-1}(\{n\})$ is infinite. I don´t have any idea how to construct that.

REPLY [5 votes]: Consider the sequence 
$$0,0,1,\color{green}{0,1,2},\color{red}{0,1,2,3},0,1,2,3,4, 0,1,2,3,4,5,\dots$$