Skip to content

Commit f8533ce

Browse files
authored
Create 633-sum-of-square-numbers.js
1 parent 46d4e77 commit f8533ce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

633-sum-of-square-numbers.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {number} c
3+
* @return {boolean}
4+
*/
5+
const judgeSquareSum = function(c) {
6+
if (c < 0) return false;
7+
const max = Math.floor(Math.sqrt(c));
8+
for (let i = 0; i < max + 1; i++) {
9+
if (Number.isInteger(Math.sqrt(c - i * i))) {
10+
return true;
11+
}
12+
}
13+
return false;
14+
};

0 commit comments

Comments
 (0)