one to one and onto problem Consinder the function
$$f\colon\mathbb N\to \mathbb N\text{ via }f(n)=2n-1.$$
Is function one to one? Is function onto?
First of all, I think it is one to one 
because when i put 


*

*$n=1$, I get $2(1)-1=1$ 

*$n=2$, I get $2(2)-1=3$

*$n=3$, I get $2(3)-1=5$

*$n=4$, I get $2(4)-1=7$


I get all odd numbers. I dont get even numbers. Therefore, this function is NOT onto. Am I right?? 
What if I get $1,2,3,4,5,6,7,8,9,\ldots$ whole numbers, then wouldn't the function be onto??
The reason function is one to one is because by using the definition, if $f(n_1)=f(n_2)$ then $n_1=n_2$.  So $2n_1-1=2n_2-1 \Rightarrow n_1=n_2$, therfore it is one to one. That's how I think and I would like to know if I'm understanding the definition of one to one correctly. 
Can anyone guide me right??
 A: Yes, you're understanding the definition of one-to-one fine. And you're correct that the given function is one-to-one. You also use the correct method at the end to show this: Since whenever $f(n_1) = f(n_2)$, you've shown it must then be the case that $n_1 = n_2$, and so you've demonstrated that the function satisfies the definition of a one-to-one function.
You're also correct that the function is not onto (in this case, not onto $\mathbb N$), and you're correct for the right reason! For any even number $m \in \mathbb N$, there does not exist an $n \in \mathbb N$ such that $f(n) = m$. E.g., we know that $10 \in \mathbb N$, but there is no $n \in \mathbb N$ such that $f(n) = 2n - 1 = 10,$, since otherwise, supposing there is an $n$ such that $2n - 1 = 10 \iff 2n = 9 \iff n = 4.5$. But $4.5 \notin \mathbb N$!, contradiction. Hence the function is not onto.
A: You are correct, if you set $f(m) = f(n)$ then you can simplify that equation to $n = m$, and this is the definition of one-to-one.
Conversely you have observed that $f(n)$ is always odd.  This is because $2n$ is even therefore $2n - 1$ is odd.  Thus for any even number, say two, it is never the case that $f(n) = 2$ and this contradicts the definition on onto.
A: You need to check your definitions.  A function is 1-1 iff whenever $f(b) = f(a)$, then $a=b$. Thus, your method of determining whether or not you have a 1-1 function is correct. Also, to check whether or not a function is onto, you pick an arbitrary element $c$ in the codomain, and see whether you can find an element $d$ in the domain such that $f(d) = c.$  For example, can you find an $n \in \mathbb{N}$ such that $f(n) = 1?$ Can you think of problematic ones?
