Suppose we have a number n. We have to check whether the number can be a perfect square number by adding 1 with it or not.
So, if the input is like n = 288, then the output will be True as after adding 1, it becomes 289 which is same as 17^2.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
from math import sqrt def solve(n): res_num = n + 1 sqrt_val = int(sqrt(res_num)) if sqrt_val * sqrt_val == res_num: return True return False n = 288 print(solve(n))