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