Largest cube that can be inscribed within the sphere | Function to find the side of the cube ; radius cannot be negative ; side of the cube ; Driver code
< ? php function largestCube ( $ r ) { if ( $ r < 0 ) return -1 ; $ a = ( float ) ( ( 2 * $ r ) / sqrt ( 3 ) ) ; return $ a ; } $ r = 5 ; echo largestCube ( $ r ) ; ? >