maths.perfect_cube¶
Functions¶
|
Check if a number is a perfect cube or not. |
|
Check if a number is a perfect cube or not using binary search. |
Module Contents¶
- maths.perfect_cube.perfect_cube(n: int) bool ¶
Check if a number is a perfect cube or not.
>>> perfect_cube(27) True >>> perfect_cube(4) False
- maths.perfect_cube.perfect_cube_binary_search(n: int) bool ¶
Check if a number is a perfect cube or not using binary search. Time complexity : O(Log(n)) Space complexity: O(1)
>>> perfect_cube_binary_search(27) True >>> perfect_cube_binary_search(64) True >>> perfect_cube_binary_search(4) False >>> perfect_cube_binary_search("a") Traceback (most recent call last): ... TypeError: perfect_cube_binary_search() only accepts integers >>> perfect_cube_binary_search(0.1) Traceback (most recent call last): ... TypeError: perfect_cube_binary_search() only accepts integers