MENU

LeetCode326. 3的幂

July 9, 2018 • Read: 283 • LeetCode

image
找到int范围内最大的3的幂的数,然后将其对n取余即可

class Solution {
    public boolean isPowerOfThree(int n) {
        return (n > 0 && Math.pow(3,21) % n == 0);
    }
}
最后编辑于: October 10, 2018
Archives Tip
QR Code for this page
Tipping QR Code