bool is_power_of_2(int n) { int i,j; if(n<=0) return false; if(n==1) return true; while(n!=1) { if(n%2==0) n=n/2; else return false; } return true; }