All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers > Sequences
Triangle Numbers (Posted on 2003-08-07) Difficulty: 3 of 5
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)?

See The Solution Submitted by Lewis    
Rating: 3.0000 (6 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
No Subject | Comment 5 of 9 |
I worded my previous post very poorly. Sorry.
Yes, I understand that 2n is even and that 2n+1 is odd when n is an int.
It is because of this that you'll see only the odd squares and never the evens coming up. Which is what I was trying so clumsily to point out.


Take the rand. pos. int. that you were given, and multiply it by eight;
then add one to this. If the result is a perfect square, then
the rand.pos. int. your were given is a triangle number.

Note - this perfect square will only be odd - you'll never have an even here.
You have 3^2 but not 4^2; you have 5^2 but not 6^2; you have 7^2 but not 8^2 & so on.

1 is a tri nbr because 1 + 8(1) = 9 = 3^2
3 is a tri nbr because 1 + 8(3) = 25 = 5^2
6 is a tri nbr because 1 + 8(6) = 49 = 7^2
10 is a tri nbr because 1 + 8(10) = 81 = 9^2
15 is a tri nbr because 1 + 8(15) = 121 = 11^2
21 is a tri nbr because 1 + 8(21) = 169 = 13^2
28 is a tri nbr because 1 + 8(28) = 225 = 15^2

  Posted by LynetteVivian on 2003-08-07 20:36:17
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (14)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information