mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 09:10:16 +00:00
8bb7b8f457
* Fix syntax for flake8 passing * fixup! Format Python code with psf/black push * # fmt: off / # fmt: on * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
17 lines
308 B
Python
17 lines
308 B
Python
def perfect_cube(n: int) -> bool:
|
|
"""
|
|
Check if a number is a perfect cube or not.
|
|
|
|
>>> perfect_cube(27)
|
|
True
|
|
>>> perfect_cube(4)
|
|
False
|
|
"""
|
|
val = n ** (1 / 3)
|
|
return (val * val * val) == n
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(perfect_cube(27))
|
|
print(perfect_cube(4))
|