Pattern · Number Theory

Number Theory interview questions

21 number theory problems tagged across recent interview reports. Drilled most heavily by american express, ibm, and infosys.

Founder's read

Number Theory is a 21-problem pattern covering divisibility, GCD, primes, modular arithmetic, and factor manipulation. It's a core competency at American Express, IBM, Infosys, and Sprinklr, where candidates encounter problems like counting primes, finding maximum GCD sums, and verifying divisibility constraints. The pattern tests whether you can reason about integers algorithmically under tight constraints. If a hard Number Theory problem lands in your live OA, StealthCoder solves it in seconds, invisible to the proctor.

Most-asked number theory problems

The hedge for the live OA

You can't drill every number theory variant before the assessment. StealthCoder runs invisibly during screen share and solves whichever variant they throw at you. No browser extension. No detection signature. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

Number Theory problems fall into recognizable buckets: prime counting and factorization, GCD/LCM operations on arrays or subsequences, modular arithmetic, and divisibility checks. You'll spot them by keywords like 'divisible', 'prime', 'GCD', 'factor', 'subsequence with equal GCD', or 'operations on array pairs'. Drill in order: prime sieves and basic factorization, then GCD problems (like maximum-gcd-sum-of-a-subarray and count-primes), then harder variants combining multiple concepts. Intermediate problems like check-if-it-is-a-good-array and count-array-pairs-divisible-by-k are where most candidates stumble. StealthCoder is the hedge for the modular arithmetic or GCD variant you didn't drill, it reads the constraint, generates the solution, and you paste it.

Companies that hire most on number theory

The honest play

21 number theory problems. You won't drill them all. Pass anyway.

Number Theory is one of the patterns interviews actually filter on. Memorizing every variant in a week is a fantasy. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds, no matter which number theory flavor lands in your live OA. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number Theory interview FAQ

How many Number Theory problems should I drill before my OA?+

Aim for 12 to 15 of the 21 problems in this pattern. Start with primes and basic GCD, then add divisibility and factor manipulation. Skip only the duplicates of concepts you've mastered. American Express, IBM, and Infosys ask 2 to 4 Number Theory problems per OA round, so depth matters more than breadth.

Is Number Theory the hardest pattern to learn?+

No. It's learnable in 2 to 3 weeks if you understand GCD, modular arithmetic, and prime factorization. The difficulty comes from recognizing when a problem *is* Number Theory disguised as a tree or array question. Once you spot the pattern, the solution is usually a known algorithm.

Which company drills Number Theory the hardest?+

American Express, IBM, Infosys, and Sprinklr each ask 4 problems in this pattern. Morgan Stanley, Nokia, and Salesforce ask 3. If you're interviewing at those firms, Number Theory is non-negotiable, don't skip it.

How do I recognize a Number Theory problem in the wild?+

Look for language about divisibility, primes, GCD, factors, or subsequences with a numeric property. Problems like count-array-pairs-divisible-by-k or find-the-maximum-factor-score-of-array are explicit. Harder ones hide the pattern: a 'valid path' problem might require GCD reasoning under the hood.

Should I memorize GCD and prime-checking code?+

Yes. Euclidean GCD and a sieve for primes should be muscle memory. You'll write them dozens of times. Modular exponentiation and factorization helpers are worth coding once and copying when needed. In your OA, you'll have no internet, StealthCoder fills that gap if you blank on the implementation.

Problem and frequency data sourced from public community-maintained interview-report repos. Problems and trademarks © LeetCode.