Check if a number can be represented as sum of two consecutive perfect cubes | Java program of the above approach ; Function to check if a number can be expressed as the sum of cubes of two consecutive numbers ; Driver Code
import java . util . * ; class GFG { static boolean isCubeSum ( int n ) { for ( int i = 1 ; i * i * i <= n ; i ++ ) { if ( i * i * i + ( i + 1 ) * ( i + 1 ) * ( i + 1 ) == n ) return true ; } return false ; } public static void main ( String [ ] args ) { int n = 35 ; if ( isCubeSum ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }