Reported September 2026
Abridgemath

Sum Multiples of 3, 5, or 7

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

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

Abridge reported this one in September 2026, and the opening angle is the data structure: there isn't one. No hash set, no array. The problem looks like a loop with a modulo check, and that's the trap. With n up to 10^9, a loop is the naive answer and the whole question is whether you spot the math. It's inclusion-exclusion over arithmetic series. If you've got the OA coming up, this is a ten-line solution once you see it. StealthCoder sits invisible on your screen as a safety net if you blank on the formula during the live assessment.

The problem

Given a positive integer n, return the sum of all positive integers from 1 through n, inclusive, that are divisible by 3, 5, or 7.
Count a number only once even when more than one of those divisors divides it.

Function
sumMultiples(n: int) → long

Examples
Example 1
n = 7
return = 21
The included values are 3, 5, 6, 7, whose sum is 21.
Example 2
n = 10
return = 40
The included values are 3, 5, 6, 7, 9, 10. Each value is counted once.
Example 3
n = 1
return = 0
No value in the inclusive range is divisible by 3, 5, or 7.

Constraints
1 <= n <= 10^9.
The result fits in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is inclusion-exclusion. Define f(k) as the sum of multiples of k up to n: m = n / k (integer division), then k * m * (m + 1) / 2. The answer is f(3) + f(5) + f(7) - f(15) - f(21) - f(35) + f(105). Pairs use the lcm, which is just the product since 3, 5, 7 are coprime. The triple is 105. The common pitfall is the brute-force loop, which does a billion iterations and times out. The second pitfall is overflow: compute k * m * (m + 1) in 64-bit. At n = 10^9 and k = 3, m is about 3.3 * 10^8, so m * (m + 1) is about 10^17, which still fits, times 3 is fine. Use long everywhere. Check your formula against n = 10, which must return 40. If you freeze on the signs in the formula during the live OA, StealthCoder can hand you the working version so you can verify it against the examples.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Sum Multiples of 3, 5, or 7 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Abridge reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sum Multiples of 3, 5, or 7 FAQ

What's the trick in the Abridge sum multiples problem?+

Inclusion-exclusion with the arithmetic series formula. Add the sums of multiples of 3, 5, and 7, subtract the sums for 15, 21, and 35 to remove double counting, then add back the sum for 105. It runs in constant time, which matters because n goes up to 10^9.

Why does the brute force loop fail here?+

The constraint is n up to 10^9. A loop checking each number runs a billion iterations, which is too slow for most assessments. The problem is built to push you toward a closed-form formula instead of iteration.

Do I need to worry about integer overflow?+

Yes. The function returns a long, and the result fits in signed 64-bit. Use 64-bit types for every intermediate value. Compute k * m * (m + 1) / 2 in long arithmetic, not int, or you'll get wrong answers on large n.

How do I check my answer quickly?+

Run the three given examples. n = 7 gives 21, n = 10 gives 40, and n = 1 gives 0. The n = 10 case is the best test because 15 and above aren't reached, so you can confirm the basic series sums before trusting the subtraction terms.

How do I prepare for this in 48 hours?+

Memorize the sum of multiples formula: k * m * (m + 1) / 2 where m = n / k. Then practice writing inclusion-exclusion for three sets by hand. Write the solution once from scratch, test it on the examples, and you're done. It's a small problem.

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

OA at Abridge?
Invisible during screen share
Get it