Given two integers N and K, the task is to count all the numbers < N which have equal number of positive divisors as K.
Input: n = 10, k = 5
2, 3 and 7 are the only numbers < 10 which have 2 divisors (equal to the number of divisors of 5)
Input: n = 500, k = 6
- Compute the number of divisor of each number < N and store the result in an array where arr[i] contains the number of divisors of i.
- Traverse arr, if arr[i] = arr[K] then update count = count + 1.
- Print the value of count in the end.
Below is the implementation of the above approach:
The above solution can be optimized using Sieve technique. Please refer Count number of integers less than or equal to N which has exactly 9 divisors for details.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Count number of integers less than or equal to N which has exactly 9 divisors
- Check if count of even divisors of N is equal to count of odd divisors
- Program to find count of numbers having odd number of divisors in given range
- Count pairs of natural numbers with GCD equal to given number
- Count of numbers whose sum of increasing powers of digits is equal to the number itself
- Count of numbers below N whose sum of prime divisors is K
- Sum of numbers in a range [L, R] whose count of divisors is prime
- Numbers in range [L, R] such that the count of their divisors is both even and prime
- Count of Numbers in Range where first digit is equal to last digit of the number
- Count of the non-prime divisors of a given number
- Count of Fibonacci divisors of a given number
- Count all perfect divisors of a number
- Number of divisors of product of N numbers
- Find the number of divisors of all numbers in the range [1, n]
- Maximum possible prime divisors that can exist in numbers having exactly N divisors
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.