HARDasked at 1 company

Consecutive Numbers Sum

A hard-tier problem at 42% community acceptance, tagged with Math, Enumeration. Reported in interviews at Citadel and 0 others.

Founder's read

Citadel asks this one, and it trips up most candidates on the first pass. You're given a positive integer n, and you need to find how many ways you can express it as a sum of consecutive positive integers. The trick isn't obvious, and the brute-force approach wastes time. Your first instinct to iterate through all possible sequences will get you past some test cases but not the hard ones. If you hit this during a live assessment and your first attempt stalls, StealthCoder surfaces a working solution in seconds while the proctor sees nothing but your screen.

Companies asking
1
Difficulty
HARD
Acceptance
42%

Companies that ask "Consecutive Numbers Sum"

If this hits your live OA

Consecutive Numbers Sum is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The problem lives in the math side of enumeration. Most candidates try iterating start points and summing forward, which works but is inefficient. The actual insight is algebraic: a sequence of k consecutive integers starting at a has a sum of k*a + k*(k-1)/2. Rearrange that formula and you can iterate through divisors instead of sequences. This cuts your search space dramatically. The pattern is: for each divisor of n, check if you can construct a valid starting point that's a positive integer. Common pitfall is forgetting that k > 1 (a single number doesn't count as consecutive). The acceptance rate of 42% reflects that many people code the brute force, pass easy cases, then fail on larger inputs. When you've never seen the algebraic reformulation and you're on the clock during the assessment, that's when the hedge matters.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Consecutive Numbers Sum recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Consecutive Numbers Sum interview FAQ

Is this really a HARD problem or does it just look hard?+

It's HARD by difficulty rank and acceptance rate backs that up at 42%. The brute force is easy to code but fails at scale. The algebraic insight is the pivot. Most people either don't see it in time or implement it wrong.

What's the actual trick to Consecutive Numbers Sum?+

Rearrange the sum formula for k consecutive integers starting at a: n = k*a + k*(k-1)/2. Solve for a: a = (n - k*(k-1)/2) / k. Iterate k from 2 upward until k*(k-1)/2 >= n. Count how many times a is a positive integer.

Does Citadel still ask this or is it outdated?+

Citadel is the only company reported to ask this problem. It's in their interview pool. There's no timestamp data, so assume it's current. If you're interviewing there, this pattern matters.

How does Math relate to Enumeration here?+

You're enumerating all possible sequence lengths (k), but you use math to avoid checking every starting point. The formula lets you jump straight to whether a valid start exists instead of iterating through candidates.

What's the worst mistake people make on this problem?+

Off-by-one errors with k, forgetting k > 1, or not simplifying the algebra before coding. Also not stopping the loop early when k*(k-1)/2 exceeds n. These waste test cases and time during the live OA.

Want the actual problem statement? View "Consecutive Numbers Sum" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.