Four Divisors
A medium-tier problem at 45% community acceptance, tagged with Array, Math. Reported in interviews at Capital One and 0 others.
Four Divisors is a medium-difficulty problem that looks simple on paper but trips up candidates who don't spot the mathematical pattern. Capital One has asked this in their assessments. The trap: most people try to brute-force divisor counting, which either times out or feels clunky. The real insight is recognizing which numbers even have exactly four divisors in the first place. If you hit this during a live OA and freeze on the optimization, StealthCoder surfaces the pattern in seconds while the proctor sees nothing.
Companies that ask "Four Divisors"
Four Divisors 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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe problem asks you to find numbers with exactly four divisors. The naive approach is iterating through each number and counting divisors by checking all values up to the square root. It works, but it's slow under constraints. The key insight: a number has exactly four divisors if it's either the cube of a prime (like 8 = 2^3) or the product of two distinct primes (like 6 = 2 × 3). Once you recognize this math pattern, you can generate candidates much faster instead of checking every single number. Array iteration and Math fundamentals are the topics, but the real challenge is seeing past the divisor-counting instinct. StealthCoder is your hedge if the pattern doesn't click before time runs out.
Pattern tags
You know the problem.
Make sure you actually pass it.
Four Divisors recycles across companies for a reason. It's medium-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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Four Divisors interview FAQ
Why does the brute-force divisor-counting approach fail?+
It works for small inputs but gets slow fast. Checking every divisor up to sqrt(n) for every number in the range adds up quickly. The problem expects you to recognize the mathematical structure of numbers with exactly four divisors and avoid the iteration entirely.
What's the actual pattern for numbers with exactly four divisors?+
Only two types: cubes of primes (like 8, 27, 125) and products of two distinct primes (like 6, 10, 14, 15). Once you identify these, you can generate or check them directly instead of counting divisors for each number.
Is this problem still asked at Capital One?+
Capital One has reported this problem in their assessments. It's medium difficulty, so expect it in a technical screen after initial phone rounds. It tests both mathematical reasoning and code efficiency.
How does this relate to the Array and Math topics?+
You iterate over a range (array thinking) and identify numbers by their prime factorization properties (math). The trick is understanding that divisor count is determined by exponents in prime factorization, not brute-force iteration.
What's the acceptance rate telling me about difficulty?+
44% acceptance rate means fewer than half of candidates pass. That's solid medium territory. Most people either get the brute-force version working but slow, or they miss the mathematical pattern entirely. Both lose points or fail test cases.
Want the actual problem statement? View "Four Divisors" on LeetCode →