Skip to content

Commit a5810d6

Browse files
authored
Create Solution.java
1 parent c6e7cc0 commit a5810d6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int consecutiveNumbersSum(int N) {
3+
int res = 0;
4+
for (int i = 1; i * (i - 1) / 2 < N; ++i) {
5+
if ((N - i * (i - 1) / 2) % i == 0) {
6+
++res;
7+
}
8+
}
9+
return res;
10+
}
11+
}

0 commit comments

Comments
 (0)