Reported April 2026
IBMmath

Count Power Products in Range

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

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

You're seeing this IBM OA question in April 2026, and it's asking you to count integers in a range that are products of powers of 3 and 5. The trick is that this isn't a brute-force iteration problem. You need to generate all valid numbers (products of 3^x * 5^y) up to your upper bound, then count how many fall in the range. It's a finite set. StealthCoder will catch the pattern if you blank on the generation logic during the live assessment.

The problem

Given two integers low and high, count how many integers in the inclusive range [low, high] can be written in the form 3x * 5y, where x and y are non-negative integers. Each valid value should be counted once, even if there is only one way to generate it. The value 1 is valid because 1 = 30 * 50. Function Description Complete the function countPowerProductsInRange in the editor below. countPowerProductsInRange has the following parameters: Returns The source thread did not provide explicit numeric bounds.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The insight is that 3^x * 5^y grows quickly, so there aren't many such numbers even in a large range. Generate them all by iterating x and y until the product exceeds your upper bound. Nest loops: for each power of 3, multiply by successive powers of 5 and collect results. Store in a set to avoid duplicates (though the form guarantees uniqueness). Then count how many fall between low and high. Common pitfall: trying to factorize every number in the range instead of generating the valid set. That's O(n log n) instead of O(log^2 n). StealthCoder will have the generation template ready if you freeze on the nested loop structure.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Count Power Products in Range 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as ugly number ii. If you have time before the OA, drill that.

⏵ The honest play

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

IBM reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Power Products in Range FAQ

How many valid numbers are typically in a range like [1, 10^18]?+

Around 2000-3000. Powers of 3 go up to roughly 3^38, powers of 5 up to 5^25. The product explodes, so the set is surprisingly small. Generating and storing them all is fast and practical.

Do I really need to handle the value 1?+

Yes. 1 = 3^0 * 5^0. Your nested loops must start at x=0, y=0. Most candidates forget to initialize or include the 1 case, so double-check your base case.

What if low is larger than all valid numbers I can generate?+

Count zero. That's correct. Filter the generated set: keep only numbers where low <= number <= high. Use binary search or a simple loop over your sorted list.

Is this still asked after the LeetCode 1348 version went viral?+

Yes. IBM and other enterprises ask it regularly. The pattern (generate constrained combinatorial set, then count membership) appears across interviews. It's not going away.

How do I avoid time limit exceeded?+

Don't iterate the range [low, high]. Generate the set of valid numbers, not the range. Nested loops over x and y are fast. Sorting the set takes O(n log n) where n is roughly 2000. You're fine.

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

OA at IBM?
Invisible during screen share
Get it