Check if a number can be represented as sum of non zero powers of 2 | C ++ implementation of the approach ; Function that return true if n can be represented as the sum of powers of 2 without using 2 ^ 0 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isSumOfPowersOfTwo ( int n ) { if ( n % 2 == 1 ) return false ; else return true ; } int main ( ) { int n = 10 ; if ( isSumOfPowersOfTwo ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }