标签:font span sof tco leetcode log color size int
思路:方法都一样,while循环而已
//2的幂 public class Solution { public boolean isPowerOfFour(int num) { if(num>1){ while(num%2==0) num/=2; } return num==1; } } //3的幂 public class Solution { public boolean isPowerOfFour(int num) { if(num>1){ while(num%3==0) num/=3; } return num==1; } } //4的幂 public class Solution { public boolean isPowerOfFour(int num) { if(num>1){ while(num%4==0) num/=4; } return num==1; } }
标签:font span sof tco leetcode log color size int
原文地址:http://www.cnblogs.com/team42/p/6890962.html