Check whether N can be a Perfect Cube after adding or subtracting K | Function to check if a number is a perfect Cube or not ; Driver code
function isPerfectCube ( x ) { var cr = Math . round ( Math . cbrt ( x ) ) ; return ( cr * cr * cr == x ) ; } function canBePerfectCube ( N , K ) { if ( isPerfectCube ( N + K ) || isPerfectCube ( N - K ) ) document . write ( " " ) ; else document . write ( " " ) ; } var N = 7 , K = 1 ; canBePerfectCube ( N , K ) ; N = 5 , K = 4 ; canBePerfectCube ( N , K ) ; N = 7 , K = 2 ; canBePerfectCube ( N , K ) ;