Check if a number can be represented as sum of two consecutive perfect cubes | Java program to implement above approach ; Function to check that a number is the sum of cubes of 2 consecutive numbers or not ; Condition to check if a number is the sum of cubes of 2 consecutive numbers or not ; Driver Code ; Function call
class GFG { static boolean isSumCube ( int N ) { int a = ( int ) Math . cbrt ( N ) ; int b = a - 1 ; return ( ( a * a * a + b * b * b ) == N ) ; } public static void main ( String [ ] args ) { int i = 35 ; if ( isSumCube ( i ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }