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)?
Starting from the equation for the nth triangle number:
T = [n(n+1)]/2
2T = n² + n
4T = 2n² + 2n
8T = 4n² + 4n
8T + 1 = 4n² + 4n + 1
8T + 1 = (2n + 1)²
So, if you are given an integer T, (8T + 1) is a perfect square iff T is a triangular number. Further, that result is the square of (2n + 1), such that T is the nth Triangle number.
|
Posted by DJ
on 2003-08-07 21:25:56 |