Triangular number equals to the sum of sequence of natural numbers from 1 to size n:
$$ T_{n}=1+2+3+\dotsb +(n-1)+n $$
This function computes the triangular number of specified size by using very efficient
implementation. It comes from basic mathematical definition of counting such sequences,
as mathematically speaking, it is defined as binomial coefficient choosing
number of distinct pairs from $ n+1 $ objects:
$$ T_{n}=1+2+3+\dotsb +(n-1)+n={\frac {n(n+1)}{2}}={\frac {n^{2}+n}{2}}{\overset {\underset {\mathrm {def} }{}}{=}}{n+1 \choose 2} $$
Function returns triangular number of passed size
Remarks
Triangular number equals to the sum of sequence of natural numbers from 1 to size n: $$ T_{n}=1+2+3+\dotsb +(n-1)+n $$
This function computes the triangular number of specified size by using very efficient implementation. It comes from basic mathematical definition of counting such sequences, as mathematically speaking, it is defined as binomial coefficient choosing number of distinct pairs from $ n+1 $ objects: $$ T_{n}=1+2+3+\dotsb +(n-1)+n={\frac {n(n+1)}{2}}={\frac {n^{2}+n}{2}}{\overset {\underset {\mathrm {def} }{}}{=}}{n+1 \choose 2} $$
Example
Simple use of finding triangular number: