Triangle number check
Description:
Description:
A triangle number is a number where n objects form an equilateral triangle (it's a bit hard to explain). For example, 6 is a triangle number because you can arrange 6 objects into an equilateral triangle:
1
2 3
4 5 6
8 is not a triangle number because 8 objects do not form an equilateral triangle:
1
2 3
4 5 6
7 8
In other words, the nth triangle number is equal to the sum of the n natural numbers from 1 to n.
Your task:
Check if a given input is a valid triangle number. Return true if it is, false if it is not (note that any non-integers, including non-number types, are not triangle numbers).
You are encouraged to develop an effective algorithm: test cases include really big numbers.
Assumptions:
You may assume that the given input, if it is a number, is always positive.
Notes:
0 and 1 are triangle numbers.
Similar Kata:
Stats:
Created | Jun 15, 2015 |
Published | Jun 15, 2015 |
Warriors Trained | 9500 |
Total Skips | 1261 |
Total Code Submissions | 25425 |
Total Times Completed | 5502 |
JavaScript Completions | 1140 |
CoffeeScript Completions | 43 |
Python Completions | 1384 |
Ruby Completions | 342 |
C# Completions | 875 |
Java Completions | 1525 |
Haskell Completions | 135 |
Clojure Completions | 125 |
Swift Completions | 262 |
Rust Completions | 95 |
Total Stars | 155 |
% of votes with a positive feedback rating | 92% of 620 |
Total "Very Satisfied" Votes | 532 |
Total "Somewhat Satisfied" Votes | 75 |
Total "Not Satisfied" Votes | 13 |