Skip to content

326. Power_of_Three

难度: Easy

刷题内容

原题连接 * https://leetcode-cn.com/problems/power-of-three/

内容描述

Given an integer, write a function to determine if it is a power of three.

###example 
1. Input: 27  -> Output: true

2. Input: 0 -> Output: false

3. Input: 9 -> Output: true

4. Input: 45 -> Output: false

题解方案

只要是3的幂次,一定能够被3的最大次方整除

coding

    bool isPowerOfThree(int n) {
        return n > 0 and 1162261467 % n ==0;
    }

我们一直在努力

apachecn/AiLearning

【布客】中文翻译组