Power of Two

class Solution {
public:
    bool isPowerOfTwo(int n) {
        //一定要处理n为0的情况
        if(n==0)
        return false;
        while(n%2==0)n=n/2;
        if (n==1)
        return true;
        else
        return false;
       
    }
};

原文地址:https://www.cnblogs.com/gofighting/p/5036223.html