MENU

LeetCode326. 3的幂

July 9, 2018 • Read: 2428 • LeetCode阅读设置

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

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