Triangular Number

You are given the following number sequence. What will be the nth term?

1 3 6 10 15 21 ..... n

View Code

The nth term can be found by adding n to the previous term
From the series we can get individual terms like this-
1st term = 1 2nd term = 2 + 1st term = 2 + 1 = 3 3rd term = 3 + 2nd term = 3 + 3 = 6 4th term = 4 + 3rd term = 4 + 6 = 10
This actually creates a triangle shape, thus called triangular number.
...
The series forms a triangle

How to solve this problem?
We can use recursion to solve this problem.