Reported September 2026
GoodScorehash table

Count Divisible Power Sums

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

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

The data structure here is a plain frequency map, and it's what turns a 8-billion-triple brute force into something that runs instantly. This GoodScore OA, reported in September 2026, asks you to count exponent triples (x, y, z) where 2^x + 3^y + 5^z is divisible by a given divisor. Exponents go up to 2000 each, so you can't enumerate everything. The pattern is hash-table counting on remainders. If you spot that in the first two minutes, the rest is typing. If you blank, StealthCoder is the safety net running invisibly during the live assessment.

The problem

For every exponent triple (x, y, z) with 0 <= x <= maxExponent2, 0 <= y <= maxExponent3, and 0 <= z <= maxExponent5, form 2^x + 3^y + 5^z.
Return the number of exponent triples whose formed number is divisible by divisor.
Different exponent triples are counted separately, even if they produce the same numeric sum.
Implement countDivisiblePowerSums with integer parameters maxExponent2, maxExponent3, maxExponent5, and divisor. Return the number of valid triples as a long.

Function
countDivisiblePowerSums(maxExponent2: int, maxExponent3: int, maxExponent5: int, divisor: int) → long

Examples
Example 1
maxExponent2 = 0
maxExponent3 = 0
maxExponent5 = 0
divisor = 3
return = 1
The only triple is (0, 0, 0), producing 1 + 1 + 1 = 3, which is divisible by 3.
Example 2
maxExponent2 = 1
maxExponent3 = 1
maxExponent5 = 0
divisor = 2
return = 2
The triples (1, 0, 0) and (1, 1, 0) produce 4 and 6. The other two sums are odd.
Example 3
maxExponent2 = 2
maxExponent3 = 2
maxExponent5 = 2
divisor = 5
return = 7
Seven of the 27 exponent triples have a power sum congruent to 0 modulo 5.

Constraints
0 <= maxExponent2, maxExponent3, maxExponent5 <= 2000
1 <= divisor <= 2000
The answer fits in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Compute every power mod divisor, not the real power. Build three arrays of residues: 2^x mod d, 3^y mod d, 5^z mod d, each built by multiplying the previous residue and reducing. Then put the 5^z residues into a count map (or an array of size divisor). Loop over every (x, y) pair, about 4 million at most, compute need = (d - (a + b) % d) % d, and add count[need] to the answer. That's roughly 4 million lookups plus building the arrays. The common pitfalls are overflow from computing real powers, forgetting the outer mod when the sum is already 0 mod d, and using int for the answer. Use a long accumulator. Triples are counted separately even when sums match, so don't dedupe anything. When divisor is 1, every triple counts. StealthCoder is the hedge if the live OA clock gets to you and the two-sum-style counting idea won't come.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Count Divisible Power Sums 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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

GoodScore reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Divisible Power Sums FAQ

What's the trick in Count Divisible Power Sums?+

Work in remainders. Precompute each power mod divisor, count the residues of the 5^z side in a frequency array, then loop over all (x, y) pairs and look up the residue that completes the sum to 0 mod divisor. It's a two-sum variant with counts.

Why can't I just brute force it?+

With each exponent up to 2000, there are about 8 billion triples. That's far too slow. Reducing to an (x, y) loop with a lookup for z cuts it to around 4 million operations, which is trivial.

How do I avoid overflow?+

Never compute 2^x directly. Keep a running residue, multiply by the base, and take mod divisor each step. Sums of residues stay under 4000, so they're safe. Only the final count needs a long, since it can reach billions.

Do equal sums from different triples count once or many times?+

Many times. The statement says different exponent triples are counted separately even if they produce the same numeric sum. So just add the frequency from the map for each (x, y) pair. No deduping, no sets.

How should I prepare for this in 48 hours?+

Practice the pattern of counting complements with a frequency map, like two-sum counting and subarray sums divisible by k. Get comfortable with modular arithmetic and the (d - r) % d complement formula. Then write this solution once from scratch and test the three examples.

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

OA at GoodScore?
Invisible during screen share
Get it