# Function as onto

I have a doubt that if a function is one-to-one then it will also be onto.

If a function $f(x)$ is defined such that $f: \mathbb{R} \rightarrow \mathbb{R}$ then if the function is many to one then it can't be onto as for being onto every element in co domain should be mapped to an element in domain. If it is many to one then there would be less elements left to be mapped to co domaim elements.

Eg. Domain and codomain each has five elements. Now out of five, three have the same image in codomain. So the rest can now only have images maximum $2$. So the function becomes many one and into. That same should apply to $\mathbb{R} \rightarrow \mathbb{R}$-type function.

Please tell if I am correct or wrong. And if wrong please tell where I am going wrong. Thank you.

In your example of 5 elements, this is correct. But when there are infinitely numbers in the domain, it is not. For example, $f(x)=e^x$ is 1-1 but not onto.
The other way, $f(x)=x(x-1)(x-2)$ is not one to one but onto.