Given two integers K and N, the task is to find the count of integers from the range [2, N – 1] whose sum of prime divisors is K
Input: N = 20, K = 7
7 and 10 are the only valid numbers.
sumPFactors(7) = 7
sumPFactors(10) = 2 + 5 = 7
Input: N = 25, K = 5
Approach: Create an array sumPF where sumPF[i] stores the sum of prime divisors of i which can be easily calculated using the approach used in this article. Now, initialise a variable count = 0 and run a loop from 2 to N – 1 and for every element i if sumPF[i] = K then increment the count.
Below is the implementation of the above approach:
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
- 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
- Maximum possible prime divisors that can exist in numbers having exactly N divisors
- Count of the non-prime divisors of a given number
- Sum of all prime divisors of all the numbers in range L-R
- Count the numbers < N which have equal number of divisors as K
- Program to find count of numbers having odd number of divisors in given range
- Check if count of even divisors of N is equal to count of odd divisors
- Find count of Almost Prime numbers from 1 to N
- Count of subarrays having exactly K prime numbers
- Sum of all the prime numbers with the count of digits ≤ D
- Count of subsequences which consists exactly K prime numbers
- Count numbers from range whose prime factors are only 2 and 3
- Count of Double Prime numbers in a given range L to R
- Count common prime factors of two numbers
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.