Advanced Number Theory Problems for Coding Interviews
30 advanced Number Theory problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 0 intermediate and 30 advanced. The companies that ask them most often are Google, Uber.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Kth Smallest Prime Fraction (Advanced)
- Count Prime Paths in a Tree (Advanced)
- Graph Connectivity With Threshold (Advanced)
- Tree of Coprimes (Advanced)
- Number of Beautiful Partitions (Advanced)
- Sum of GCDs of All Pairs (Advanced)
- Smallest Discrete Logarithm (Advanced)
- Sum of Divisor Function Totals (Advanced)
- Count Coprime Pairs in Array (Advanced)
- Product of All Divisors (Advanced)
- Matrix Determinant Modulo Prime (Advanced)
- Matrix Rank Modulo Prime (Advanced)
- Binomial Modulo Small Prime (Advanced)
- Count Sequences With GCD One (Advanced)
- Count Numbers With Prime Digit Sum (Advanced)
- Fibonacci GCD Modulo (Advanced)
- Primes in Segment (Advanced)
- Euler Totient Preimage Count (Advanced)
- Smallest Primitive Root of Prime (Advanced)
- Smallest Solution of Congruence System (Advanced)
- Modular Square Root Smallest (Advanced)
- Carmichael Function Value (Advanced)
- Number of Primitive Roots Modulo N (Advanced)
- Pillai Arithmetical Function (Advanced)
- Polynomial GCD Degree Modulo Prime (Advanced)
- Non-Abundant Sums (Advanced)
- Quadratic Primes Coefficient Product (Advanced)
- Longest Consecutive Prime Sum Below N (Advanced)
- Jordan Totient Function (Advanced)
- Nth Lucky Number (Advanced)
Related
Frequently asked questions
How do I get good at number theory problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run number theory problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.