Let's define f(n) as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like this:
Make sure when you are drawing the lines, you don't have an intersection of more than two lines.
Your task
Given a number n, print f(n).
Test cases:
n | f(n)
---+-----
1 | 1
2 | 2
3 | 4
4 | 8
5 | 16
6 | 31
7 | 57
8 | 99
9 | 163
You can see more here.
Using built-in sequence generators is not allowed.
Remember, this is code-golf, so the code with the smallest number of bytes wins.
If you guys want the formula, here it is: