位运算 1000&0111==0,明白这个即可 if(((N-1)&N)==0){ System.out.println("是二的整数倍"); }else{ System.out.println("不是二的整数倍"); }