Given a number N, find the next perfect
square greater than N.
Input Format:
Integer input from stdin.
Output Format:
Perfect square greater than N.
Example Input:
10
Output:
16
Answers
Answered by
3
The given problem is solved using language - Python.
from math import sqrt
n=int(input('Enter an integer number: '))+1
while int(sqrt(n))!=sqrt(n):
n=n+1
print('Next Perfect Square Number is:',n)
- An integer number is taken as input.
- A loop is created which run till any perfect square is found. After each iteration of loop, the value of the variable 'n' is incremented by 1.
- When the loop is terminated, the next perfect square is found. So, it is displayed on the screen.
#1
Enter an integer number: 10
Next Perfect Square Number is: 16
#2
Enter an integer number: 16
Next Perfect Square Number is: 25
Attachments:
Similar questions