Given an integer N, the task is to find all of its divisors using its prime factorization.
Input: N = 6
Output: 1 2 3 6
Input: N = 10
Output: 1 2 5 10
Approach: As every number greater than 1 can be represented in it’s prime factorization as p1a1*p2a2*……*pkak, here pi is a prime number, k ≥ 1 and ai is a positive integer.
Now all the possible divisors can be generated recursively if the count of occurrence of every prime factor of n is known. For every prime factor pi, it can be included x times where 0 ≤ x ≤ ai. First, find the prime factorization of n using this approach and for every prime factor, store it with the count of it’s occurrence.
Below is the implementation of the above approach:
1 3 2 6
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Sum of Factors of a Number using Prime Factorization
- Sum of all the prime divisors of a number
- Check if a number has prime count of divisors
- Check if a number is divisible by all prime divisors of another number
- Pollard's Rho Algorithm for Prime Factorization
- Prime Factorization using Sieve O(log n) for multiple queries
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Find sum of divisors of all the divisors of a natural number
- Sum of all prime divisors of all the numbers in range L-R
- Count of numbers below N whose sum of prime divisors is K
- Querying maximum number of divisors that a number in a given range has
- Find the largest good number in the divisors of given number N
- Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors
- First triangular number whose number of divisors exceeds N
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.