Skip to content

Practice Consecutive Numbers Sum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#829
LeetCode Problem

Consecutive Numbers Sum

Problem Statement

Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.

Source: Consecutive Numbers Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 5
Output
2

# Example 2

Input
n = 9
Output
3

# Example 3

Input
n = 15
Output
4

Constraints

1 <= n <= 10^9

Related LeetCode Problems

Practice more problems similar to Consecutive Numbers Sum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.