如何逆取n次根

How to inverse taking the n-th root

假设我有这个 python 脚本:

a = 2 ** 10
b = a ** # Code to reverse the process done for a.
print(a) # Prints 1024
print(b) # Should print 2

我该怎么做?

您可能想要找到该值的 xth 根。为此,您将结果提高到幂的倒数。所以,你的问题的答案是:

a = 2 ** x
b = a ** (1/x) # Code to reverse the process done for a.
print(a) # Prints 1024
print(b) # Should print 2