Monday, July 16, 2018

How do you calculate Cube Root of a number in Java?

Problem statement: Find the cube root of a number in java.
public class CubeRootExe {
    public static void main(String args[]) {
        double cbRt = cubeRoot(8);
        System.out.println(cbRt);
    }
    public static double cubeRoot(double n) {
        return Math.cbrt(n);
    }
}
Output:
2.0

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...