Perfect cubes in a range | A Simple Method to count cubes between a and b ; Traverse through all numbers in given range and one by one check if number is prime ; Check if current number ' i ' is perfect cube ; Driver Code
< ? php function printCubes ( $ a , $ b ) { for ( $ i = $ a ; $ i <= $ b ; $ i ++ ) { for ( $ j = 1 ; $ j * $ j * $ j <= $ i ; $ j ++ ) { if ( $ j * $ j * $ j == $ i ) { echo $ j * $ j * $ j , " " ; break ; } } } } $ a = 1 ; $ b = 100 ; echo " Perfect ▁ cubes ▁ in ▁ given ▁ range : STRNEWLINE ▁ " ; printCubes ( $ a , $ b ) ; ? >