+ 1

write a program in C# to Check whether given number is power of 2 or not

24th Nov 2016, 4:43 PM
Deepashri Bharat Barve
Deepashri Bharat Barve - avatar
2 odpowiedzi
+ 3
if((x != 0) && ((x & (x - 1)) == 0)) { //the number is power of 2. }
24th Nov 2016, 6:18 PM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar