Math-326-Power of Three
2018-01-26 20:56
134 查看
Description:
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
Solution:
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
Solution:
class Solution { public boolean isPowerOfThree(int n) { while(n > 1){ if(n % 3 != 0) return false; n /= 3; } return n == 1; } }
相关文章推荐
- Leetcode 326 Power of Three
- 231,338,326,Power of Two(Three,Four)Counting Bits 类似的技巧题
- [326]Power of Three
- 326. Power of Three
- Leetcode_326_Power of Three
- leetcode 326---Power of Three,区分floor与rint
- Leetcode 326 Power of Three 数论
- LeetCode 231,326,342 --Power of Two & Three & Four
- leetcode_326_Power of Three(easy)(C++)
- leetcode 326 [easy]--- Power of Three
- 326. Power of Three
- 【C语言】 LeetCode 326 Power of Three
- LeetCode 326 Power of Three
- leetcode——326——Power of Three
- Leetcode 326 : Power of Three
- LeetCode 第 326 题 (Power of Three)
- [python语法巩固][leetcode326][Power of Three]
- LeetCode 326 Power of Three(3的幂)(递归、Log函数)
- leetcode 326 Power of Three C++
- LeetCode-326 Power of Three