Given two integers N and K, the task is to find the Nth root of the K.
Input: N = 3, K = 8
Cube root of 8 is 2. i.e. 23 = 8
Input: N = 2, K = 16
Square root of 16 is 4, i.e. 42 = 16
Approach: The idea is to use logarithmic function to find the Nth root of K.
Let D be our Nth root of the K,
Apply logK on both the sides –
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find minimum number of Log value needed to calculate Log upto N
- Square root of a number using log
- Find Cube root of a number using Log function
- How is the time complexity of Sieve of Eratosthenes is n*log(log(n))?
- Program to compute log a to any base b (logb a)
- Digital Root (repeated digital sum) of square of an integer using Digital root of the given integer
- Find Nth positive number whose digital root is X
- Smallest root of the equation x^2 + s(x)*x - n = 0, where s(x) is the sum of digits of root x.
- Check if a number can be expressed as power | Set 2 (Using Log)
- Prime Factorization using Sieve O(log n) for multiple queries
- Find square root of number upto given precision using binary search
- Square root of a number without using sqrt() function
- Find root of a number using Newton's method
- Floor value Kth root of a number using Recursive Binary Search
- Write an iterative O(Log y) function for pow(x, y)
- Find n-th element in a series with only 2 digits (4 and 7) allowed | Set 2 (log(n) method)
- Iterated Logarithm log*(n)
- Find the ln(X) and log10X with the help of expansion
- Find nth Fibonacci number using Golden ratio
- Find Nth even length palindromic number formed using digits X and Y
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.