Reported December 2024
Capital Onemath

Sum Digits Until One

Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Capital One OA. Under 2s to a working solution.
Founder's read

Capital One asked this in December 2024, and it's simpler than it sounds: keep summing a number's digits until you're left with a single digit. The catch is recognizing this isn't a loop problem in disguise. It's a math pattern that can be solved in constant time. Most candidates code the loop and pass, but knowing the trick lets you write it in three lines. StealthCoder catches you if you blank on the recurrence, but the pattern is stable and repeats across tech interviews.

Pattern and pitfall

The naive approach: repeatedly sum digits until one remains. This works but takes O(log n) per iteration. The real trick is the digital root, which has a closed formula: if n is 0, return 0; if n % 9 is 0 and n is not 0, return 9; otherwise return n % 9. This works because digit sums preserve modulo 9 equivalence. The problem tests whether you recognize a mathematical shortcut or defaulted to simulation. In the OA, either passes, but the formula answer signals pattern recognition. If you freeze on the math, StealthCoder feeds you the loop structure instantly.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Sum Digits Until One cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as add digits. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Capital One's OA.

Capital One reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sum Digits Until One FAQ

Is there a one-line formula or do I have to loop?+

There's a digital root formula: return 1 + ((n - 1) % 9) for n > 0, else 0. It's O(1) and shocks interviewers. The loop approach also works fine in the assessment and is safer if you're not confident in the math.

What's the main pitfall candidates hit?+

Off-by-one errors in the formula, or not handling n=0 correctly. Another trap: writing a loop but forgetting that you need the sum itself, not its index. Test with 38 (3+8=11, 1+1=2) and 0 to lock in your logic.

Does Capital One care which approach I use?+

No. The loop is straightforward and passes. The formula is faster and cleaner. Both are acceptable. What matters is correctness and clarity. Pick the one you trust under pressure in the OA.

How do I prepare for this in 48 hours?+

Implement the loop version twice from scratch. Then spend 10 minutes understanding why (n-1) % 9 + 1 works. You don't need to memorize the formula, just know it exists and when to use it.

Is this problem still commonly asked in late 2024?+

Yes. It's a classic digit-manipulation problem and shows up regularly in tech screening. Capital One likes it because it tests both simulation and mathematical insight. Expect to see it or similar variants.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Capital One.

OA at Capital One?
Invisible during screen share
Get it