Number of perfect cubes between two given numbers | Function to count cubes between two numbers ; Traverse through all numbers ; Check if current number ' i ' is perfect cube ; Driver code
function countCubes ( a , b ) { for ( let i = a ; i <= b ; i ++ ) for ( let j = 1 ; j * j * j <= i ; j ++ ) if ( j * j * j == i ) cnt ++ ; return cnt ; } let a = 7 , b = 30 ; document . write ( " " + countCubes ( a , b ) ) ;