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
- Check if a number has an odd count of odd divisors and even count of even divisors
- Divisors of n-square that are not divisors of n
- Check if count of even divisors of N is equal to count of odd divisors
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Square free semiprimes in a given range using C++ STL
- Find sum of divisors of all the divisors of a natural number
- Nth Square free number
- Square Free Number
- Maximum possible prime divisors that can exist in numbers having exactly N divisors
- Find smallest perfect square number A such that N + A is also a perfect square number
- Count square and non-square numbers before n
- Count elements in the given range which have maximum number of divisors
- Program to find count of numbers having odd number of divisors in given range
- Count of Fibonacci divisors of a given number
- Count of the non-prime divisors of a given number
- Sum of all perfect square divisors of numbers from 1 to N
- Check if a number is perfect square without finding square root
- Smallest N digit number whose sum of square of digits is a Perfect Square
- Check if a number is a perfect square having all its digits as a perfect square
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.