题目原址
https://leetcode.com/problems/power-of-three/description/
题目描述
Given an integer, write a function to determine if it is a power of three.
解题思路
求一个数是否是3的幂指数,与题231.Power of Two解题思路一致
AC代码
public boolean isPowerOfThree(int n) {
if(n == 0)
return false;
if(n == 1)
return true;
while(n % 3 == 0) {
n = n / 3;
if(n == 1)
return true;
}
return false;
}
2万+



被折叠的 条评论
为什么被折叠?



