public static int changeNumber (int num) { if(num == 0)return 2; int temp = num; int count = 0; int flag = 1; int base = 0; while(temp!=0){ if((temp&flag) == 0){ count++; } if(count==2)break; temp = temp>>>1; base++; } if(count == 0)return (int) (num+Math.pow(2,base+1)); return (int) (num+Math.pow(2,base)); }