判断一个数字是否是平方数
DESCRIPTION
Given an integral number, determine if it’s a square number:
In mathematics, a square number or perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself.
The tests will always use some integral number, so don’t worry about that in dynamic typed languages.
Examples
1 | -1 => false |
SOLUTION
- 方法一:
1 | var isSquare = function (n) { |
- 方法二:
1 | function isSquare(n) { |