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)?
take the rand. pos. int. that you were given, and multiply it by eight
then add one to this
if the result is both odd and a perfect square, then
the rand.pos. nbr your were given is a triangle number
1 is a triangle nbr because 1 + 8(1) = 9 (result is both odd and square)
3 is a triangle nbr because 1 + 8(3) = 25 (result is both odd and square)
28 is a triangle nbr because 1 + 8(28) = 225 (result is both odd and square)