Skip to content

Commit f9634a2

Browse files
committed
add 1025
1 parent 0b6fe34 commit f9634a2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1025-divisor-game.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* * @param {number} N
3+
* * @return {boolean}
4+
* */
5+
const divisorGame = function(N) {
6+
let idx = 0
7+
let x
8+
while(x = chk(N)) {
9+
idx++
10+
N = N - x
11+
}
12+
if(idx === 0) return false
13+
return idx % 2 === 1 ? true : false
14+
};
15+
16+
function chk(num) {
17+
for(let i = 1; i < num; i++) {
18+
if(num % i === 0) return i
19+
}
20+
return false
21+
}

0 commit comments

Comments
 (0)