Given a positive integer n. Find the minimum number which divide n to make it a perfect square.
Input : n = 50 Output : 2 By Dividing n by 2, we get which is a perfect square. Input : n = 6 Output : 6 By Dividing n by 6, we get which is a perfect square. Input : n = 36 Output : 1
A number is perfect square if all prime factors appear even number of times. The idea is to find the prime factor of n and find each prime factor power. Now, find and multiply all the prime factor whose power is odd. The resultant of the multiplication is the answer.
This article is contributed by Anuj Chauhan. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Minimum digits to remove to make a number Perfect Square
- Find smallest perfect square number A such that N + A is also a perfect square number
- Least number to be added to or subtracted from N to make it a Perfect Square
- Minimum divisor of a number to make the number perfect cube
- Find the Next perfect square greater than a given number
- Find the Largest N digit perfect square number in Base B
- Array range queries to find the number of perfect square elements with updates
- Find the minimum number to be added to N to make it a prime number
- Number of times the largest perfect square number can be subtracted from N
- Previous perfect square and cube number smaller than number 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
- Find all Factors of Large Perfect Square Natural Number in O(sqrt(sqrt(N))
- Find minimum number of coins that make a given value
- Find the minimum number to be added to N to make it a power of K