Python/maths/perfect_cube.py
Nika Losaberidze 8bb7b8f457
Fix syntax for flake8 passing (#2096)
* 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>
2020-06-12 06:51:47 +02:00

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))