Perfect Cube | Java program to check whether the given number N is the perfect cube or not ; 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
class GFG { static void perfectCube ( int N ) { int cube ; for ( int i = 0 ; i <= N ; i ++ ) { cube = i * i * i ; if ( cube == N ) { System . out . println ( " Yes " ) ; return ; } else if ( cube > N ) { System . out . println ( " NO " ) ; return ; } } } public static void main ( String [ ] args ) { int N = 216 ; perfectCube ( N ) ; } }