Check if a number is a perfect cube or not. >>> perfect_cube(27) True >>> perfect_cube(4) False
(n: int)
| 1 | def perfect_cube(n: int) -> bool: |
| 2 | """ |
| 3 | Check if a number is a perfect cube or not. |
| 4 | |
| 5 | >>> perfect_cube(27) |
| 6 | True |
| 7 | >>> perfect_cube(4) |
| 8 | False |
| 9 | """ |
| 10 | val = n ** (1 / 3) |
| 11 | return (val * val * val) == n |
| 12 | |
| 13 | |
| 14 | def perfect_cube_binary_search(n: int) -> bool: |
nothing calls this directly
no outgoing calls
no test coverage detected