2022-03-27 20:46:41 +08:00
< p > Given an integer < code > n< / code > , return < em > the number of ways you can write < / em > < code > n< / code > < em > as the sum of consecutive positive integers.< / em > < / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:46:41 +08:00
< pre >
< strong > Input:< / strong > n = 5
< strong > Output:< / strong > 2
< strong > Explanation:< / strong > 5 = 2 + 3
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:46:41 +08:00
< pre >
< strong > Input:< / strong > n = 9
< strong > Output:< / strong > 3
< strong > Explanation:< / strong > 9 = 4 + 5 = 2 + 3 + 4
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 20:46:41 +08:00
< pre >
< strong > Input:< / strong > n = 15
< strong > Output:< / strong > 4
< strong > Explanation:< / strong > 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = n < = 10< sup > 9< / sup > < / code > < / li >
< / ul >