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
< ? php function isCubeFree ( $ n ) { if ( $ n == 1 ) return false ; for ( $ i = 2 ; $ i * $ i * $ i <= $ n ; $ i ++ ) if ( $ n % ( $ i * $ i * $ i ) == 0 ) return false ; return true ; } function printCubeFree ( $ n ) { for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) if ( isCubeFree ( $ i ) ) echo $ i . " " ; } $ n = 20 ; printCubeFree ( $ n ) ; ? >