@dong.wang.1694 share my two methods without using any loop / recursion

one:the max of int is 2^31-1,so I use Math.pow(2,31)(double) to take a remainder of n.

two:use Math.log10() to solve it.

public class Solution { public boolean isPowerOfTwo(int n) { return n>0&&(Math.log10(n)/Math.log10(2))%1==0;and also you can use n&(n-1)to judge or Integer.bitCount()to do it.