Number Theory interview questions
21 number theory problems tagged across recent interview reports. Drilled most heavily by american express, ibm, and infosys.
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
| # | Problem | Diff | # Companies | Pass % |
|---|---|---|---|---|
| 01 | Count Primes | MEDIUM | 10 | 35% |
| 02 | Add Digits | EASY | 3 | 68% |
| 03 | Check If It Is a Good Array | HARD | 3 | 61% |
| 04 | The kth Factor of n | MEDIUM | 3 | 70% |
| 05 | Minimize Length of Array Using Operations | MEDIUM | 2 | 35% |
| 06 | Check if Point Is Reachable | HARD | 1 | 43% |
| 07 | Count Array Pairs Divisible by K | HARD | 1 | 30% |
| 08 | Count the Number of Ideal Arrays | HARD | 1 | 57% |
| 09 | Count Valid Paths in a Tree | HARD | 1 | 34% |
| 10 | Find the Maximum Factor Score of Array | MEDIUM | 1 | 40% |
| 11 | Find the Number of Subsequences With Equal GCD | HARD | 1 | 29% |
| 12 | Make K-Subarray Sums Equal | MEDIUM | 1 | 37% |
| 13 | Maximize Score After N Operations | HARD | 1 | 58% |
| 14 | Maximum GCD-Sum of a Subarray | HARD | 1 | 36% |
| 15 | Minimize the Maximum of Two Arrays | MEDIUM | 1 | 31% |
| 16 | Minimum Deletions to Make Array Divisible | HARD | 1 | 58% |
| 17 | Number of Different Subsequences GCDs | HARD | 1 | 42% |
| 18 | Number of Subarrays With LCM Equal to K | MEDIUM | 1 | 40% |
| 19 | Prime In Diagonal | EASY | 1 | 36% |
| 20 | Split the Array to Make Coprime Products | HARD | 1 | 28% |
| 21 | Ugly Number III | MEDIUM | 1 | 30% |
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 StealthCoderNumber 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
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.