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.
- Count number of integers less than or equal to N which has exactly 9 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 below N whose sum of prime divisors is K
- 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 all perfect divisors of a number
- Number of divisors of product of N numbers
- Count elements in the given range which have maximum number of divisors
- Find the number of divisors of all numbers in the range [1, n]
- Count numbers whose XOR with N is equal to OR with N
- Count numbers whose difference with N is equal to XOR with N
- Count different numbers that can be generated such that there digits sum is equal to 'n'
- Maximum count of equal numbers in an array after performing given operations
- Count numbers in a range having GCD of powers of prime factors equal to 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.