For an equilateral triangle with $n$ dots on a side, how many lines are needed to connect each dot to every other dot? 
For an equilateral triangle of side length $n$ dots, as shown in this diagram below, construct a
  function, $f(n)$, which outputs the number of lines needed to connect up every dot to every other dot. A straight line through three or more dots counts
  as only one line! E.g. $f(3) = 9$ and $f(4) = 24$.


Can anyone point me in the right direction with this problem? Perhaps tell me what area of mathematics or what concepts would help me solve this? If this is a trivial problem don't give the answer but tell let me know. Thanks.
 A: Here's a solution for the problem described, i.e. if the shape is an equilateral triangle whose sides are $n$ equally spaced dots. This is assuming the dots along the sides of the triangle are the only dots.
First, count the number of dots. There are $n$ dots along one edge, with one of those dots being shared with the other two edged. Then, there are $n-1$ new dots along a second edge, with one of those shared with the final edge. Finally, there are $n-2$ dots remaining on the third edge. This gives a total of $n+(n-1)+(n-2) = 3(n-1)$ dots.
The number of edges connecting two dots is then $\binom{3(n-1)}{2} = \frac{3(n-1)(3n-4)}{2}$. However, along each side of the triangle, there are $\binom{n}{2} = \frac{n(n-1)}{2}$ edges along the same line. So, we need to subtract all but one of these (the edge connecting the corners) for each side, totaling $3[\binom{n}{2}-1] = \frac{3(n+1)(n-2)}{2}$.
Thus, the total number of necessary lines is $$ f(n) = \binom{3(n-1)}{2}-3\left[\binom{n}{2}-1\right] = 3(n^2-3n+3) $$
This gives $f(2) = 3, f(3) = 9, f(4) = 21, f(5) = 39$ and so on.
