This seems to be simple but I cannot find a way to do it. I need to show whether the cube root of an integer is integer or not. I used is_integer()
float method
In SymPy there is also the integer_nthroot
function which will quickly find the integer nth root of a number and tell you whether it was exact, too:
>>> integer_nthroot(primorial(12)+1,3)
(19505, False)
So your function could be
def is_perfect_cube(x): return integer_nthroot(x, 3)[1]
(And because SymPy is open source, you can look at the routine to see how integer_nthroot
works.)