I'm trying to find an onto function $f: \mathbb{Q} \to\mathbb{N}$
I'm somewhere along the lines of $f(q) = |(1 - q)| + q$ for non integers, but I'm not sure where to go from there.
I'm trying to find an onto function $f: \mathbb{Q} \to\mathbb{N}$
I'm somewhere along the lines of $f(q) = |(1 - q)| + q$ for non integers, but I'm not sure where to go from there.
On
This is the classical example to show that the rationals are countable and that defines a bijection from $\mathbb{Q}$ to $\mathbb{N}$:
You proceed taking $f(1/1)=0$ and then enumerate the fractions you encounter on the path described by the arrows, skipping the ones you have already considered previously.
Thanks to the help of the users commenting on the question, I understand the problem. $f$($m$/$n$)=|$m$|+1 is an onto function, as long as $m$/$n$ is in reduced form.