I want to find some simple surjective function from $\mathbb{N}$ to $\mathbb{Q}$.
Since $\mathbb{Q}$ is countable, it should be possible.
Can someone find such function?
I want to find some simple surjective function from $\mathbb{N}$ to $\mathbb{Q}$.
Since $\mathbb{Q}$ is countable, it should be possible.
Can someone find such function?
Consider $A=\{2^p3^q, p,q\geq 1 \}$, $B=\{5^r7^s, r,s \geq 1\}$, $A\bigcup B\subset N$, define $f(2^p3^q)={p\over q}, f(5^r7^s)=-{r\over s}$ and $f(n)=0$ if $n\in N-A\bigcup B$.
Let $$f(n)=\frac{(n\bmod \lfloor\sqrt n\rfloor)- \lfloor\sqrt n/2\rfloor}{\lfloor\sqrt[4]n\rfloor} $$
First, put the set of all half-open intervals $[n, n+1)$, $n \in \Bbb{Z}$, into bijection with the naturals, numbering them $I_1, I_2,...$. The rational numbers in $[n, n+1)$ can be counted as follows: $n, n+1/2, n+1/3, n+ 2/3,...$: first partially order the rationals in that interval by their denominators written in lowest form, then order the sets of rationals with the same denominator by their numerators. This is a total order and you can just count them one after the other. Clearly this is a bijection. Now you can define $f(k,m)$ to be the $m$th rational listed in $I_k$.This a bijection between $\Bbb{Q}$ and $\Bbb{N}^2$, and the latter set is countable by a canonical bijection.