Logarithm tricks for Competitive Programming | Python3 implementation to find Kth root of the number ; Function to find the Kth root of the number ; Driver code
import math NEW_LINE def kth_root ( n , k ) : NEW_LINE INDENT return ( pow ( k , ( ( 1.0 / k ) * ( math . log ( n ) / math . log ( k ) ) ) ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 8.0 NEW_LINE k = 3 NEW_LINE print ( round ( kth_root ( n , k ) ) ) NEW_LINE DEDENT