Reported September 2024
Ciscomath

Find Out Prime or Composite

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

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

Cisco asked this in September 2024, and it's a straight math problem that catches people off guard because they overthink it. You get a number, you return whether it's prime or composite. Sounds simple until you're live and your brain blanks on the definition or you write an inefficient loop. StealthCoder sits invisible during the OA and feeds you the pattern in real time if you freeze. This one rewards clarity and speed over cleverness.

Pattern and pitfall

The trick is recognizing you don't need fancy algorithms here. A prime number has exactly two divisors: 1 and itself. Composite has more. The pattern is a simple math check: iterate from 2 to the square root of n, and if any number divides n evenly, it's composite. Stop early. Most candidates waste time checking every number up to n, or they confuse the edge cases (1 is neither prime nor composite, 2 is prime). StealthCoder acts as your safety net during the OA if you blank on the implementation, letting you nail the logic without the panic.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Find Out Prime or Composite 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 by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Cisco reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Out Prime or Composite FAQ

Is there a trick to handling the edge cases?+

Yes. 1 is neither prime nor composite. 2 is the only even prime. After that, check only odd divisors from 3 to sqrt(n). If you remember those rules, you'll avoid the most common mistakes.

How do I know when to stop checking divisors?+

Stop at the square root of n. If n has a divisor larger than sqrt(n), it must also have a divisor smaller than sqrt(n). So you only need to check up to sqrt(n) to know for sure.

What's the time complexity I should aim for?+

O(sqrt(n)) is the standard. That's fast enough for most inputs Cisco will throw at you. Don't overcomplicate with sieves unless the problem explicitly asks for multiple primes.

Does Cisco expect a specific output format?+

The problem likely asks for a boolean, a string ('Prime' or 'Composite'), or an integer (1 for prime, 0 for composite). Read the exact spec in the OA. Different platforms format differently.

How do I prepare for this in 48 hours if I'm shaky on the math?+

Write out the definition of prime and composite. Code the sqrt check once. Test on 2, 3, 4, 15, 17. Run it. That's enough. The problem is about clean implementation, not deep math knowledge.

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

OA at Cisco?
Invisible during screen share
Get it