Check if a number can be represented as sum of two consecutive perfect cubes | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool 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 ; } int main ( ) { int n = 35 ; if ( isCubeSum ( n ) ) cout << " Yes " ; else cout << " No " ; }