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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a number is a perfect square having all its digits as a perfect square
- Minimum digits to remove to make a number Perfect Square
- Count numbers upto N which are both perfect square and perfect cube
- Check if a number is perfect square without finding square root
- Least number to be added to or subtracted from N to make it a Perfect Square
- Count of elements to be multiplied with integers to make each pair of Array a perfect square
- Find the Next perfect square greater than a given number
- Array range queries to find the number of perfect square elements with updates
- Find the Largest N digit perfect square number in Base B
- Find pairs of elements from two different arrays whose product is a perfect square
- Find a subarray of size K whose sum is a perfect square
- Number of times the largest perfect square number can be subtracted from N
- Previous perfect square and cube number smaller than number N
- Largest number that is not a perfect square
- Check if given number is perfect square
- Largest factor of a given number which is a perfect square
- Largest perfect square number in an Array
- Largest Divisor of a Number not divisible by a perfect square
- Largest N digit Octal number which is a Perfect square
- Check whether the number can be made perfect square after adding K