Skip to content

Commit b6a3ad6

Browse files
authored
Update 829-consecutive-numbers-sum.js
1 parent 901263d commit b6a3ad6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

829-consecutive-numbers-sum.js

+18
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,21 @@ const consecutiveNumbersSum = function (N) {
99
}
1010
return count
1111
}
12+
13+
// another
14+
15+
/**
16+
* @param {number} N
17+
* @return {number}
18+
*/
19+
const consecutiveNumbersSum = function(N) {
20+
let res = 0
21+
for(let i = 1; i <= N; i++) {
22+
const diff = i * (i - 1) / 2
23+
const nd = N - diff
24+
if(nd <= 0) break
25+
if(nd % i === 0) res++
26+
}
27+
28+
return res
29+
};

0 commit comments

Comments
 (0)