Given an integer N, the task is to check if it can be expressed as a product of exactly K prime divisors.
Input: N = 12, K = 3 Output: Yes Explanation: 12 can be expressed as product of 2×2×3. Input: N = 14, K = 3 Output: No Explanation: 14 can be only expressed as product of 2×7.
To solve the problem mentioned above we are given the value N and we will find the maximum number of values we can split N into. We can represent prime factorization of N as where pi are the prime factors of N and ai are the exponents. We know that total number of divisors of N is . Therefore, we can observe that we have to check whether it is possible to represent N as product of K numbers or not. If the maximum split is less than K then it is not possible to express it in exactly K prime divisors, else it is always possible.
Time Complexity: O(sqrt(N))
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if a prime number can be expressed as sum of two Prime Numbers
- Check whether a number can be expressed as a product of single digit numbers
- Check if a number has prime count of divisors
- Check if a number is divisible by all prime divisors of another number
- Check if N can be expressed as product of 3 distinct numbers
- Check if a number can be expressed as a^b | Set 2
- Check if a number can be expressed as 2^x + 2^y
- Check if a number can be expressed as power | Set 2 (Using Log)
- Sum of all the prime divisors of a number
- Check if a number can be expressed as sum two abundant numbers
- Check if a number can be expressed as a sum of consecutive numbers
- Check if a number can be expressed as x^y (x raised to power y)
- Number of divisors of product of N numbers
- Count of the non-prime divisors of a given number
- Generating all divisors of a number using its prime factorization
- Maximum possible prime divisors that can exist in numbers having exactly N divisors
- Check if each element of the given array is the product of exactly K prime numbers
- Check if product of array containing prime numbers is a perfect square
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- N expressed as sum of 4 prime 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.