Triangle numbers are :
1,3,6,10,15,21,28.
Somebody tells you a random positive integer of any size. Is there a quick way to work out if it is a triangle number or not (in other words, without going through all of the triangle numbers untill you get to a number as high or higher as the integer you've been told)?
Let us call a proposed triangular number x.
From the triangular number formula, we assume x is a triangular number:
x = (n^2 + n)/2
Multiply booth sides by 2:
2x = n^2 + n
0 = n^2 + n – 2x
This can be broken down into a quadratic equation with
a = 1 , b = 1 , c = -2x
By using the quadratic formula:
n = (-1±(1+8x)^0.5)/2
In order to prove that x is a triangular number, it must be substituted into the above equation with a positive integer resulting for n.