借助於sympy.perfect_power()方法,我們可以找到兩個整數b和e,使它們等於給定的數字n。
用法:
perfect_power(n)
參數:
n - 它表示一個整數。
返回:
返回整數(b,e)的元組,使得be== n。
範例1:
# import perfect_power() method from sympy
from sympy import perfect_power
n = 64
# Use perfect_power() method
b, e = perfect_power(n)
print("n = {}".format(n))
print("b = {} and e = {}.".format(b, e))
print("{}^{} == {}".format(b, e, n))
輸出:
n = 64 b = 2 and e = 6. 2^6 == 64
範例2:
# import perfect_power() method from sympy
from sympy import perfect_power
n = 64
# Use perfect_power() method
b, e = perfect_power(n, big = False)
print("n = {}".format(n))
print("b = {} and e = {}.".format(b, e))
print("{}^{} == {}".format(b, e, n))
輸出:
n = 64 b = 8 and e = 2. 8^2 == 64
相關用法
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.get_blocking()用法及代碼示例
- Python sympy.apart()用法及代碼示例
- Python sympy.nC()用法及代碼示例
- Python os.set_blocking()用法及代碼示例
- Python os.getcwd()用法及代碼示例
- Python os.access()用法及代碼示例
- Python dict pop()用法及代碼示例
- Python sympy.Add()用法及代碼示例
- Python sympy.nP()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 Python | sympy.perfect_power() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。