Nth root of a number using log | C ++ 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
#include <bits/stdc++.h> NEW_LINE double kthRoot ( double n , int k ) { return pow ( k , ( 1.0 / k ) * ( log ( n ) / log ( k ) ) ) ; } int main ( void ) { double n = 81 ; int k = 4 ; printf ( " % lf ▁ " , kthRoot ( n , k ) ) ; return 0 ; }