Attempt to write a function with cubed log runtime complexity $O(\log^3 n)$ I'm learning Data Structures and Algorithms now, I have a practical question that asked to write a function with O(log3n), which means log(n)*log(n)*log(n).

public void run(int n) {
    for (int i = 1; i &lt; n; i *= 2) {
        for (int j = 1; j &lt; n; j *= 2) {
            for (int k = 1; k &lt; n; k *= 2) {
                System.out.println("hi");
            }
        }
    }
}


I have come with this solution, but it seems not correct. Please help me out.
Your program is correct. Your could also iterate Math.Log(n)*Math.Log(n)*Math.Log(n) times. Not sure if that is considered cheating.