Given an integer N, the task is to check if the count of divisors of N is prime or not.
Input: N = 13
The divisor count is 2 (1 and 13) which is prime.
Input: N = 8
The divisors are 1, 2, 4 and 8.
Approach: Please read this article to find the count of divisors of a number. So find the maximum value of i for every prime divisor p such that N % (pi) = 0. So the count of divisors gets multiplied by (i + 1). The count of divisors will be (i1 + 1) * (i2 + 1) * … * (ik + 1).
It can now be seen that there can only be one prime divisor for the maximum i and if N % pi = 0 then (i + 1) should be prime. The primality can be checked in sqrt(n) time and the prime factors can also be found in sqrt(n) time. So the overall time complexity will be O(sqrt(n)).
Below is the implementation of the above approach:
- Count of the non-prime divisors of a given number
- Check if a number can be expressed as a product of exactly K prime divisors
- Check if a number is divisible by all prime divisors of another number
- Numbers in range [L, R] such that the count of their divisors is both even and prime
- Maximum count of pairwise co-prime and common divisors of two given numbers
- Generating all divisors of a number using its prime factorization
- Product of divisors of a number from a given list of its prime factors
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Check if a number exists with X divisors out of which Y are composite
- Count number of integers less than or equal to N which has exactly 9 divisors
- Count of square free divisors of a given number
- Count all pairs of divisors of a number N whose sum is coprime with N
- Check whether the given number is Wagstaff prime or not
- Find sum of divisors of all the divisors of a natural number
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Check if the number is a Prime power number
- Check if a number can be written as a sum of 'k' prime numbers
- Check if all Prime factors of number N are unique or not
- Check if there exists a number with X factors out of which exactly K are prime
- Sum of all prime divisors of all the numbers in range L-R
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.
Improved By : AnkitRai01