Given an integer, write a function to determine if it is a power of three.
I personally don't understand the purpose of this question..... math????
bool isPowerOfThree(int n) {
if(n <= 0) return false;
return pow(3, round(log10(n)/log10(3))) == n;
}
810

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



