Show $f: \Bbb{N}\to\mathbb{N}$ defined by $f(x)=\frac{x(x+1)}{2}$. Show that $f$ is injective but not surjective. 
Consider the function $f: \mathbb{N} \to \mathbb{N}$ defined by $f(x)=\frac{x(x+1)}{2}$. Show that $f$ is injective but not surjective.

So I started by assuming that $f(a)=f(b)$ for some $a,b \in \mathbb{N}$.
I want to show that $a=b$.
$$\Rightarrow \frac{a(a+1)}{2} = \frac{b(b+1)}{2}\\
\Rightarrow a(a+1)=b(b+1) \\
\Rightarrow a^2+a=b^2+b$$
I don't know where to go from here.
 A: Suppose $a \ne b$ at that point. Then, without loss of generality, $b > a$. But then $b^2 + b > a^2 + a$. Why?  Because squaring the inequality gives you $b^2 > a^2$ (which holds since $a,b \ge 1$, or $0$ depending on your convention for $\Bbb N$), and you can add the original $b > a$ inequality to  this one and maintain it.
Thus, you have to have equality.
A: First notice that $\sum_{n=1}^x n=\frac{x(x+1)}{2}=f(x)$ for all $x\in\mathbb{N}$, thus if $f(a)=f(b)$ with $a\neq b$, we can suppose without loss of generality that $a<b$, thus
$$ \sum_{k=a+1}^b k=\sum_{k=1}^b k-\sum_{k=1}^a k=f(b)-f(a)=0 $$
which is not because $\sum_{k=a+1}^b k\geqslant a+1>0$ so $a=b$.
 You can also say that if $f(a)=f(b)$, then $a^2+a=b^2+b$ as you wrote, so that $$b-a=a^2-b^2=(a+b)(a-b)$$ if $a\neq b$, then $a-b\neq 0$ and thus $1=-(a+b)<0$ which is not so that $a=b$.
A: To show $f(x)=f(y)$ implies $x=y$, show the contrapositive, namely, 
$$a\neq b\implies f(a)\neq f(b).$$
So suppose WLOG that $a<b$. Then $a+1<b+1$, so that $a(a+1)<a(b+1)<b(b+1)$, but then $$\frac{a(a+1)}{2}\neq\frac{b(b+1)}{2}.$$
Thus $f$ is injective from $\Bbb N$ to $\Bbb N$.

To show $f$ is not surjective, consider $n$ such that $f(n)=4$.
