Triangle Numbers. Simon’s own code

Now this was pretty amazing! Simon’s new own code, that he so nonchalantly wrote while “having a break” from practicing recursive functions, generates “triangular numbers”.

A triangular number or triangle number counts the objects that can form an equilateral triangle. The nth triangular number is equal to the sum of the n natural numbers from 1 to n. The sequence of triangular numbers is

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406 …

https://www.youtube.com/watch?v=Y2QaShP8vHY

 

“This particular piece of code works with any sequence”, Simon said:

Triangle Numbers (This particular piece of code works with any sequence) 15 Apr 2017

He tried to build the whole triangle but got stuck.

Leave a comment