829. Consecutive Numbers Sum Hard
1/**
2 * [829] Consecutive Numbers Sum
3 *
4 * Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.
5 *
6 * Example 1:
7 *
8 * Input: n = 5
9 * Output: 2
10 * Explanation: 5 = 2 + 3
11 *
12 * Example 2:
13 *
14 * Input: n = 9
15 * Output: 3
16 * Explanation: 9 = 4 + 5 = 2 + 3 + 4
17 *
18 * Example 3:
19 *
20 * Input: n = 15
21 * Output: 4
22 * Explanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
23 *
24 *
25 * Constraints:
26 *
27 * 1 <= n <= 10^9
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/consecutive-numbers-sum/
33// discuss: https://leetcode.com/problems/consecutive-numbers-sum/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn consecutive_numbers_sum(n: i32) -> i32 {
39 0
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_829() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.