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:
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 whether the number can be made perfect square after adding K
- Check whether the number can be made palindromic after adding K
- Check whether N can be a Perfect Cube after adding or subtracting K
- Check if a number is a perfect square having all its digits as a perfect square
- Find smallest perfect square number A such that N + A is also a perfect square number
- Check if given intervals can be made non-overlapping by adding/subtracting some X
- Check if a number is perfect square without finding square root
- Queries to check whether all the elements can be made positive by flipping signs exactly K times
- Check whether an Array can be made 0 by splitting and merging repeatedly
- Count numbers upto N which are both perfect square and perfect cube
- Smallest N digit number whose sum of square of digits is a Perfect Square
- Number of times the largest perfect square number can be subtracted from N
- Count N-digit numbers made up of X or Y whose sum of digits is also made up of X or Y
- Find the character made by adding all the characters of the given string
- Check if X and Y can be made zero by using given operation any number of times
- Check if given array can be made 0 with given operations performed any number of times
- Check if number can be made prime by deleting a single digit
- C Program to check whether a number is a Perfect Cube or not
- Check if given number is 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.