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
import java . util . * ; class GFG { static int canBeSumofConsec ( int n ) { n = 2 * n ; return ( ( n & ( n - 1 ) ) != 0 ) ? 1 : 0 ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . print ( canBeSumofConsec ( n ) + "NEW_LINE"); } }