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 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 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 perfect square number in an Array
- Largest factor of a given number which is a perfect square
- 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 1
- Largest Divisor of a Number not divisible by a perfect square
- Find the minimum number of operations required to make all array elements equal
- Minimum number of operations on a binary string such that it gives 10^A as remainder when divided by 10^B