Nth non | Python3 program to find n - th non - square number . ; function to find the nth Non - Square Number ; conversion from int to long double is necessary in order to preserve decimal places after square root . ; calculating the result ; initializing the term number ; Print the result
import math NEW_LINE def findNthNonSquare ( n ) : NEW_LINE INDENT x = n ; NEW_LINE ans = x + math . floor ( 0.5 + math . sqrt ( x ) ) ; NEW_LINE return int ( ans ) ; NEW_LINE DEDENT n = 16 ; NEW_LINE print ( " The " , n , " th ▁ Non - Square ▁ number ▁ is " , findNthNonSquare ( n ) ) ; NEW_LINE