📜  Python| sympy.perfect_power() 方法

📅  最后修改于: 2022-05-13 01:54:25.531000             🧑  作者: Mango

Python| sympy.perfect_power() 方法

sympy.perfect_power()方法的帮助下,我们可以找到两个整数be使得b e等于给定的数字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