Program to print non square numbers | Function to check perfect square ; function to print all non square number ; variable which stores the count ; not perfect square ; Driver code
function isPerfectSquare ( n ) { if ( n < 0 ) return false ; let root = Math . round ( ( Math . sqrt ( n ) ) ) ; return n == root * root ; } function printnonsquare ( n ) { let count = 0 ; for ( let i = 1 ; count < n ; ++ i ) { if ( ! isPerfectSquare ( i ) ) { document . write ( i + " " ) ; count ++ ; } } } let n = 10 ; printnonsquare ( n ) ;