Program to print non square numbers | Javascript program to print first n non - square numbers . ; Print curr_count numbers . curr_count is current gap between two square numbers . ; Skip a square number . ; Count of next non - square numbers is next even number . ; Driver code
function printNonSquare ( n ) { let curr_count = 2 , num = 2 , count = 0 ; while ( count < n ) { for ( let i = 0 ; i < curr_count && count < n ; i ++ ) { document . write ( num + " " ) ; count ++ ; num ++ ; } num ++ ; curr_count += 2 ; } } let n = 10 ; printNonSquare ( n ) ;