Calculate the nth triangular number for a provided number.
number
Time complexity: O(1)
Space complexity: O(1)
The number to calculate the triangular number for
The nth triangular number for the provided value
value
Math
triangularNumber(2); // 3 Copy
triangularNumber(2); // 3
Calculate the nth triangular number for a provided bigint.
bigint
triangularNumber(2n); // 3n Copy
triangularNumber(2n); // 3n
Calculate the nth triangular number for a provided
number
.Time complexity: O(1)
Space complexity: O(1)