Cube Free Numbers smaller than n | Returns true if n is a cube free number , else returns false . ; Check for all possible divisible cubes ; Print all cube free numbers smaller than n . ; Driver code
function isCubeFree ( n ) { if ( n == 1 ) return false ; for ( let i = 2 ; i * i * i <= n ; i ++ ) if ( n % ( i * i * i ) == 0 ) return false ; return true ; } function prletCubeFree ( n ) { for ( let i = 2 ; i <= n ; i ++ ) { if ( isCubeFree ( i ) ) { document . write ( i + " " ) ; } } } let N = 20 ; prletCubeFree ( N ) ;