Number Theory
14 problems · 8 with full explanations
0 Easy4 Medium3 Hard
Number theory problems involve primes, divisors, GCD, modular arithmetic, and number bases. Key algorithms: Sieve of Eratosthenes (O(n log log n) primes), Euclidean GCD (O(log n)), and modular exponentiation (O(log n)). Most competitive problems use modulo 10⁹+7.
How to practice
To practice Number Theory problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the number theory pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.
All Number Theory problems
- 878.Nth Magical NumberHard
- 1766.Tree of CoprimesUnknown
- 1994.The Number of Good SubsetsUnknown
- 2197.Replace Non-Coprime Numbers in ArrayUnknown
- 2338.Count the Number of Ideal ArraysMedium
- 2344.Minimum Deletions to Make Array DivisibleHard
- 2523.Closest Prime Numbers in RangeMedium
- 2572.Count the Number of Square-Free SubsetsUnknown
- 2601.Prime Subtraction OperationHard
- 2807.Insert Greatest Common Divisors in Linked ListMedium
- 2818.Apply Operations to Maximize ScoreUnknown
- 3116.Kth Smallest Amount With Single Denomination CombinationMedium
- 3272.Find the Count of Good IntegersUnknown
- 3343.Count Number of Balanced PermutationsUnknown