VOOZH about

URL: https://www.geeksforgeeks.org/dsa/find-cube-root-of-a-number-using-log-function/

⇱ Find Cube root of a number using Log function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Find Cube root of a number using Log function

Last Updated : 12 Jul, 2025

Given the number N, the task is to find the cube root using the log function.
Examples:

Input: N = 8 
Output: 2.000000
Input: N = 27 
Output: 3.000000 
 


Approach: To solve the problem mentioned above we will use log() function, according to the following formula:

Let cube root of N be d. 
=> ?N = d 
=> N(1/3) = d 
Now, apply log on both sides: 
log3 (N(1/3)) = log3 (d) 
=> log3 (d) = 1/3 * log3 (N) 
=> d = 3(1/3 * log3 (N)) 
 


Below is the implementation of the above problem: 


Output
2.00 

Time complexity: O(log2(log3n))
Auxiliary space: O(1)

Comment
Article Tags:
Article Tags: