Check if number formed by joining two Numbers is Perfect Cube | Function to check if a number is a perfect Cube or not ; Function to check if concatenation of two numbers is a perfect cube or not ; Convert numbers to string using to_string ( ) ; Concatenate the numbers and convert it into integer ; Check if concatenated value is perfect cube or not ; Driver Code
function isPerfectCube ( x ) { var cr = Math . round ( Math . cbrt ( x ) ) ; return ( cr * cr * cr == x ) ; } function checkCube ( a , b ) { s1 = a . toString ( ) ; s2 = b . toString ( ) ; var c = parseInt ( s1 + s2 ) ; if ( isPerfectCube ( c ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } var a = 6 ; var b = 4 ; checkCube ( a , b ) ;