Given a number N, the task is to find the next perfect square greater than N.
Input: N = 6 Output: 9 9 is a greater number than 6 and is also a perfect square Input: N = 9 Output: 16
- Find the square root of given N.
- Calculate its floor value using floor function in C++.
- Then add 1 to it.
- Print square of that number.
Below is the implementation of above approach:
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.
- Find smallest perfect square number A such that N + A is also a perfect square number
- Find minimum number to be divided to make a number a perfect square
- Find the Largest N digit perfect square number in Base B
- Array range queries to find the number of perfect square elements with updates
- 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))
- Perfect cube greater than a given number
- Perfect Square factors of a Number
- Largest number that is not a perfect square
- Check if given number is 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 perfect square number in an Array
- Largest factor of a given number which is a perfect square
- Check whether the number can be made perfect square after adding K
- Check whether the number can be made perfect square after adding 1
- Largest N digit Octal number which is a Perfect square
- Least number to be added to or subtracted from N to make it a Perfect Square
- Check if a given number is a Perfect square using Binary Search
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.