(1/2)*X*(X-1)
You can see this by counting. 1 team won't have a match, two teams will play each other once, 3 teams will have 3 matches (AB, AC, BC), 4 will need 6: (AB, CD, AC, BD, AD, BC), and so on... meaning that the number of matches needed is determined by the series of triangular numbers, which has the formula above.