Sastry Numbers
Last Updated :
24 Mar, 2021
Given an integer N, the task is to check N is a Sastry number.
A number N is a Sastry Number if N concatenated with N + 1 gives a perfect square.
Examples:
Input: N = 183
Output: Yes
Explanation:
183 + 184 = 183184 = 4282
Input: N = 28
Output: No
Approach: The idea is to convert the number to string and concatenate N and (N + 1) and then again convert it to an integer. Now we just have to check if the final number is a perfect square. If yes then the given number is a Sastry number.
Below is the implementation of the above approach:
References: OEIS
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...