Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 565 Bytes

0326._Power_Of_Three.md

File metadata and controls

28 lines (24 loc) · 565 Bytes

326. Power_of_Three

难度: Easy

刷题内容

原题连接

内容描述

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;
    }