Perfect Cube | Function to check if a number is a perfect Cube or not ; Iterate from 1 - N ; Find the cube of every number ; Check if cube equals N or not ; Driver code ; Function call
def perfectCube ( N ) : NEW_LINE INDENT cube = 0 ; NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT cube = i * i * i ; NEW_LINE if ( cube == N ) : NEW_LINE INDENT print ( " Yes " ) ; NEW_LINE return ; NEW_LINE DEDENT elif ( cube > N ) : NEW_LINE INDENT print ( " NO " ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 216 ; NEW_LINE perfectCube ( N ) ; NEW_LINE DEDENT