Check if a number can be expressed as a sum of consecutive numbers |  ; Updating n with 2 n ; ( n & ( n - 1 ) ) = > Checking whether we can write 2 n as 2 ^ k if yes ( can 't represent 2n as 2^k) then answer 1  if no (can represent 2n as 2^k) then answer 0
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long int canBeSumofConsec ( long long int n ) { n = 2 * n ; return ( ( n & ( n - 1 ) ) != 0 ) ; } int main ( ) { long long int n = 10 ; cout << canBeSumofConsec ( n ) << " STRNEWLINE " ; }