Given an integer N, the task is to count the number of square-free divisors of the given number.
A number is said to be square-free, if no prime factor divides it more than once, i.e., the largest power of a prime factor that divides N is one.
Input: N = 72
Explanation: 2, 3, 6 are the three possible square free numbers that divide 72.
Input: N = 62290800
For every integer N, find its factors and check if it is a square-free number or not. If it is a square-free number then increase the count or proceed to the next number otherwise. Finally, print the count which gives us the required number of square-free divisors of N.
Time complexity: O(N3/2)
Follow the steps below to solve the problem:
- From the definition of square-free numbers, it can be understood that by finding out all the prime factors of the given number N, all the possible square-free numbers that can divide N can be found out.
- Let the number of prime factors of N be X. Therefore, 2X – 1 square-free numbers can be formed using these X prime factors.
- Since each of these X prime factors is a factor of N, therefore any product combination of these X prime factors is also a factor of N and thus there will be 2X – 1 square free divisors of N.
- N = 72
- Prime factors of N are 2, 3.
- Hence, the three possible square free numbers generated from these two primes are 2, 3 and 6.
- Hence, the total square-free divisors of 72 are 3( = 22 – 1).
Below is the implementation of the above approach:
Time Complexity: O(N)
Auxiliary Space: O(1)
- Minimum number of Square Free Divisors
- Square Free Number
- Nth Square free number
- Count of the non-prime divisors of a given number
- Count all perfect divisors of a number
- Count of Fibonacci divisors of a given number
- Count number of integers less than or equal to N which has exactly 9 divisors
- Count the numbers < N which have equal number of divisors as K
- Check if a number has prime count of divisors
- Count all pairs of divisors of a number N whose sum is coprime with N
- Check if count of even divisors of N is equal to count of odd divisors
- Count elements in the given range which have maximum number of divisors
- Square free semiprimes in a given range using C++ STL
- Program to find count of numbers having odd number of divisors in given range
- Count of elements having odd number of divisors in index range [L, R] for Q queries
- Divisors of n-square that are not divisors of n
- Sum of all perfect square divisors of numbers from 1 to N
- Count of ways to represent N as sum of a prime number and twice of a square
- 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
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.