Given an integer N, the task is to check whether N the given number can be made a perfect square after adding 1 to it.
3 + 1 = 4 which is a perfect square i.e. 22
5 + 1 = 6 which is not a perfect square.
Approach: Check whether n + 1 is a perfect square or not by taking the square root of n + 1 and checking whether it is an integer. If it is then n + 1 is a perfect square and n is a sunny number.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check whether the number can be made perfect square after adding K
- Check whether the number can be made palindromic after adding K
- Check if a number is perfect square without finding square root
- Check if given number is perfect square
- Check if a given number is a Perfect square using Binary Search
- Find smallest perfect square number A such that N + A is also a perfect square number
- Check whether N can be a Perfect Cube after adding or subtracting K
- Smallest N digit number whose sum of square of digits is a Perfect Square
- Check perfect square using addition/subtraction
- Check if product of array containing prime numbers is a perfect square
- Largest number that is not a perfect square
- Find minimum number to be divided to make a number a perfect square
- Previous perfect square and cube number smaller than number N
- Number of times the largest perfect square number can be subtracted from N
- Find the Next perfect square greater than a given number
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.