Leetcode - Power of Two
Leetcode - Power of Four

Leetcode - Power of Three

violet posted @ Jun 09, 2020 12:37:47 AM in 算法 with tags Algorithm Golang math , 209 阅读

https://leetcode.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

Example 2:

Input: 0
Output: false

 

func isPowerOfThree(n int) bool {
    return n > 0 &&  1162261467 % n == 0
}

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter