Find Cube root of a number using Log function | Java program to Find Cube root of a number using Logarithm ; Function to find the cube root ; Calculate the cube root ; Return the final answer ; Driver code
class GFG { static double cubeRoot ( double n ) { double ans = Math . pow ( 3 , ( ( 1.0 / 3 ) * ( Math . log ( n ) / Math . log ( 3 ) ) ) ) ; return ans ; } public static void main ( String [ ] args ) { double N = 8 ; System . out . printf ( " % .2f " , cubeRoot ( N ) ) ; } }