Nth root of a number using log | Python3 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 numpy as np NEW_LINE def kthRoot ( n , k ) : NEW_LINE INDENT return pow ( k , ( ( 1.0 / k ) * ( np . log ( n ) / np . log ( k ) ) ) ) NEW_LINE DEDENT n = 81 NEW_LINE k = 4 NEW_LINE print ( " % .6f " % kthRoot ( n , k ) ) NEW_LINE