给出N,判断N是否为2的正整数幂次?
(结果后面静下心来,5分钟就想通了,醉了)
不考虑消耗,这样写也👌🏻。仅以此记吧~
boolean f(int N)
{
while(N%2==0)
{
N=N/2
if(N==1)
return true
}
return false
}
给出N,判断N是否为2的正整数幂次?
(结果后面静下心来,5分钟就想通了,醉了)
不考虑消耗,这样写也👌🏻。仅以此记吧~
boolean f(int N)
{
while(N%2==0)
{
N=N/2
if(N==1)
return true
}
return false
}