package com.oracle.test;

import org.testng.annotations.Test;

public class IsPowerTest {

public boolean isTwoPower(int num) {
return (num & (num-1)) == 0;
}

@Test
void testIsPower() {
System.out.println(isTwoPower(9));
}
}

输出如下,
判断一个数是不是2的N次方_oracle