Skip to content

Commit 7871e59

Browse files
authored
Create 829-consecutive-numbers-sum.js
1 parent 6ab430d commit 7871e59

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

829-consecutive-numbers-sum.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {number} N
3+
* @return {number}
4+
*/
5+
const consecutiveNumbersSum = function (N) {
6+
let count = 1
7+
for (let k = 2; k < Math.sqrt(2 * N); k++) {
8+
if ((N - (k * (k - 1)) / 2) % k === 0) count++
9+
}
10+
return count
11+
}

0 commit comments

Comments
 (0)