TITLE: bijection between $\mathbb{N}$ and $\mathbb{N}\times\mathbb{N}$
QUESTION [7 upvotes]: I understand that both $\mathbb{N}$ and $\mathbb{N}\times\mathbb{N}$ are of the same cardinality by the Shroeder-Bernstein theorem, meaning there exists at least one bijection between them. But I can't figure out what such a bijection would be. The paper that I'm reading gives an example of an injective function $f:\mathbb{N}\to\mathbb{N}\times\mathbb{N}$, $f(n)=(0,n)$, and an injective function $g:\mathbb{N}\times\mathbb{N}\to\mathbb{N}$, $g(a,b)=2^a3^b$. I was thinking perhaps if there were some way to combine these two, I could find a bijection, but I have no idea how to go about that or if it's even possible.
What is an example of a bijection between these two sets, and please explain the process by which you found it?

REPLY [2 votes]: Assuming than $\mathbb N$ contains $0$, then 
$$f(m,n)=2^m(2n+1)-1$$
is a bijection from $\mathbb N \times \mathbb N$ to $\mathbb N$.
The inverse $g: \mathbb N \to \mathbb N \times \mathbb N$ is simple: $g(n)=(a,b)$ where $a$ is the largest power of $2$ dividing $n+1$ and $2b+1$ is the largest odd number dividing $n+1$.
If you don't include $0$ in $\mathbb N$, all you need is replace $m,n$ by $m-1, n-1$.