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))
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Maximum possible prime divisors that can exist in numbers having exactly N divisors
- Check if a prime number can be expressed as sum of two Prime Numbers
- Count prime numbers that can be expressed as sum of consecutive prime numbers
- Check whether a number can be expressed as a product of single digit numbers
- Check if N can be expressed as product of 3 distinct numbers
- Elements of Array which can be expressed as power of prime numbers
- Check if a number can be expressed as x^y (x raised to power y)
- Check if a number can be expressed as a sum of consecutive numbers
- Check if a number can be expressed as power | Set 2 (Using Log)
- 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 sum two abundant numbers
- Check if a number N can be expressed in base B
- Check if a number can be expressed as sum of two Perfect powers
- Check if a given number can be expressed as pair-sum of sum of first X natural numbers
- Check if each element of the given array is the product of exactly K prime numbers
- Check if a number has an odd count of odd divisors and even count of even divisors
- Maximum number of prime factors a number can have with exactly x factors
- Product of divisors of a number from a given list of its prime factors
- Check if an integer can be expressed as a sum of two semi-primes
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.