Given a positive integer N, the task is to find the total number of distinct power of prime factor of the given number N.
Input: N = 216
216 can be expressed as 2 * 22 * 3 * 32.
The factors satisfying the conditions are 2, 22, 3 and 32 as all of them are written as distinct positive powers of prime factors.
Input: N = 24
24 can be expressed as 2 * 22 * 3
Approach: The idea is to find all the prime factors of N and how many times each prime factor divides N.
Suppose the prime factor ‘p’ divides N ‘z’ times, then the required distinct prime factors are p, p2, …, pi.
To find the number of distinct primes factor for prime number p find the minimum value of i such that (1 + 2 + …. + i) ≤ z.
Therefore, for each prime number dividing N K number of times, find the minimum value of i such that (1 + 2 + …. + i) ≤ K.
Below is the implementation of the above approach:
Time complexity: O(sqrt(N))
- Exactly n distinct prime factor numbers from a to b
- Count all the numbers less than 10^6 whose minimum prime factor is N
- Count of subarrays whose products don't have any repeating prime factor
- Check whether count of distinct characters in a string is Prime or not
- Sort an array according to the increasing count of distinct Prime Factors
- Count of subsequences of length atmost K containing distinct prime elements
- Count of distinct sums that can be obtained by adding prime numbers from given arrays
- Prime Factor
- k-th prime factor of a given number
- N-th prime factor of a given number
- Find power of power under mod of a prime
- Least prime factor of numbers till n
- Find largest prime factor of a number
- Find sum of a number and its maximum prime factor
- Sum of largest prime factor of each number less than equal to n
- Nearest element with at-least one common prime factor
- Queries on the sum of prime factor counts in a range
- Sum of Maximum and Minimum prime factor of every number in the Array
- Find the sum of power of bit count raised to the power B
- Smallest number greater than n that can be represented as a sum of distinct power of k
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.