Given two numbers N and K, the task is to check whether the given number N can be made a perfect square after adding K to it.
Input: N = 7, K = 2
7 + 2 = 9 which is a perfect square.
Input: N = 5, K = 3
5 + 3 = 8 which is not a perfect square.
Approach: The idea is to compute the value of N + K and check if it is a perfect square or not. In order to check if a number is a perfect square or not, refer to this article.
Below is the implementation of the above approach:
Note: Similar, it can be checked whether (N – K) can be a perfect square or not, by replacing ‘+’ with ‘-‘ sign in the above function.
- Check whether the number can be made perfect square after adding 1
- 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 whether the number formed by concatenating two numbers is a perfect square or not
- Check whether N can be a Perfect Cube after adding or subtracting K
- 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
- Number of times the largest perfect square number can be subtracted from N
- Largest perfect square number in an Array
- Find the Next perfect square greater than a given number
- Largest factor of a given number which is a perfect square
- Largest N digit Octal number which is a Perfect square
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.
Improved By : Yash_R