How many students were there if a total of 870 photographs were exchanged After the graduation exercises at school, the students exchanged photographs with each others. How many students were there if a total of $870$ photographs were exchanged ?
My attempt:  
I used the combination formula $^nC_r$  where $n = 870$ and $r=2$ . 
But my answer seems to be wrong.
Where i am wrong? 
 A: Let's start from the beginning.
We know $870$ photographs were shared. If $n$ is the number of students (which is what we want to solve for), then we know each student gives a photograph to every other student: each of the $n$ students gives a photo to $n - 1$ students. So the total number of photographs is $$\begin{align} n(n - 1) & = 870\tag{$\dagger$}\\ \\ n^2 - n - 870 & = 0 \\ \\ (n-30)(n+29) & = 0 \\ \\ \iff n = 30 \;& \text{or} \; n = -29\end{align}$$ We are needing a positive number of students here, so we take $n = 30$. 
Therefore, there are $\;30\;$ graduating students here, each of whom gives a photograph to $n - 1 = 29$ other students: $30\times 29 = 870 $ photographs exchanged.
This would be the same result if we computed the number of students for whom $\bf 2$ photographs were exchanged for every pair of $n$ students: Again: $n$ is our unknown number of students, $\binom{n}{2}$ is the number of pairs of students: $$\begin{align} 2 \times \binom{n}{2} & = 870 \\ \\ 2\times \frac{n!}{2! \,(n - 2)!} & = 870 \\ \\ 2\times \frac{n\cdot (n-1)}{2} & = 870 \\ \\ n(n-1) & = 870...\tag{see $\dagger$}\end{align}$$
