Nth root of a number using log | Java implementation to find the Kth root of a number using log ; Function to find the Kth root of the number using log function ; Driver Code
import java . util . * ; class GFG { static double kthRoot ( double n , int k ) { return Math . pow ( k , ( ( 1.0 / k ) * ( Math . log ( n ) / Math . log ( k ) ) ) ) ; } public static void main ( String args [ ] ) { double n = 81 ; int k = 4 ; System . out . printf ( " % .6f " , kthRoot ( n , k ) ) ; } }