[Solved] Triangular numbers patterns [closed]


I’ll give you a hint since this looks like a h/w assignment.

if you check the graphics you posted, for computing (n)th number you’re just adding a new row to the (n-1)th figure at the bottom with n new dots.

starting with

1 -> 1
2 -> 1+2 = 3
3 -> 3+3 = 6
4 -> 6+4 = 10

or f(n) = f(n-1) + n with initial condition f(0)=0

Now, you can recursively solve this problem at this point. However, we can go a step further and compute a closed form formula as well.

 f(1) = f(0) + 1
 f(2) = f(1) + 2
 ...
 f(n) = f(n-1) + n
+------------------
 f(n) = f(0) + 1 + 2 + ... + n = n*(n+1)/2

1

solved Triangular numbers patterns [closed]