Search
⌘K

Leetcode 829. Consecutive Numbers Sum

Count how many ways a given n (1 ≤ n ≤ 10^9) can be written as a sum of consecutive positive integers. The core challenge is finding lengths k and starting values a satisfying n = k*(2a+k-1)/2 — which reduces to a number-theoretic/divisor-counting check (equivalently counting appropriate divisors of n) that can be done in O(sqrt(n)).

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid October, 2025

Meta

Senior

Comments

Your account is free and you can post anonymously if you choose.