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
- 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
- Number of times the largest perfect square number can be subtracted from N
- Check if a number is perfect square without finding square root
- Find all Factors of Large Perfect Square Natural Number in O(sqrt(sqrt(N))
- Find minimum number of coins that make a given value
- Check if given number is perfect square
- Largest number that is not a perfect square
- Largest factor of a given number which is a perfect square
- Largest perfect square number in an Array
- Find minimum number of merge operations to make an array palindrome
- Find the minimum number of elements that should be removed to make an array good
- Check whether the number can be made perfect square after adding K