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
- Check if a number is a perfect square having all its digits as a perfect square
- Smallest subarray of size greater than K with sum greater than a given value
- Perfect cube greater than a given number
- Previous perfect square and cube number smaller than number N
- Count numbers upto N which are both perfect square and perfect cube
- 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 the next Factorial greater than N
- Next greater number than N with exactly one bit different in binary representation of N
- Next greater Number than N with the same quantity of digits A and B
- Elements greater than the previous and next element in an Array
- Count of Array elements greater than all elements on its left and next K elements on its right
- Find minimum number to be divided to make a number a perfect square
- Find next greater number with same set of digits
- Largest number with maximum trailing nines which is less than N and greater than N-D
- Largest number less than N with digit sum greater than the digit sum of N
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Find all Factors of Large Perfect Square Natural Number in O(sqrt(sqrt(N))
- Find the Largest N digit perfect square number in Base B
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.