With the help of sympy.perfect_power() method, we can find two integers b and e such that be is equal to the given number n.
Syntax:
perfect_power(n)Parameter:
n – It denotes an integer.Returns:
Returns a tuple of integers (b, e) such that be == n.
Example #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)) |
Output:
n = 64 b = 2 and e = 6. 2^6 == 64
Example #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)) |
Output:
n = 64 b = 8 and e = 2. 8^2 == 64
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Difference between Method Overloading and Method Overriding in Python
- class method vs static method in Python
- Get() method for dictionaries in Python
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Line detection in python with OpenCV | Houghline method
- Python | os._exit() method
- Python | os.WEXITSTATUS() method
- Python | os.abort() method
- Python | os.renames() method
- Python | os.lseek() method
- Python | PyTorch sin() method
- Python | Sympy Line.is_parallel() method
- Python PIL | GaussianBlur() method
- Python | Numpy np.hermefit() method
- Python | Numpy np.hermevander() method
- Python groupby method to remove all consecutive duplicates
- Python | Method Overloading
- Run Python script from Node.js using child process spawn() method
- Difference between Method and Function in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

