Leetcode 326:Power of Three
2016-02-24 23:59
281 查看
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?
Credits:
Special thanks to @dietpepsi for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
Follow up:
Could you do it without using any loop / recursion?
Credits:
Special thanks to @dietpepsi for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
//给定一个整数,编写函数判断它是否为3的幂 class Solution { public: bool isPowerOfThree(int n) { if(n>1) { while(n%3==0) n=n/3; } return n==1; } };
相关文章推荐
- 判断字符串是否为数字-备
- Xcode7 使用WebView loadRequest发送HTTP请求的问题
- <Perl语言入门>读书笔记 | 二. 标量数据
- zstu 2554 过河卒
- NPOI开发手记
- 千万要小心STL的iterator失效[难度:初级]
- centos 关机和重启命令详解
- Java疯狂讲义第五章笔记
- 关于iOS上的对象映射公用方法-备
- IntelliJ IDEA 15 创建maven项目
- Mina(三)
- 显示时间的类
- 17. Letter Combinations of a Phone Number
- activity向Fragment传值
- [leetcode] Divide and Conquer
- 写在前面的话
- protobuf
- 二维表的数据可以被封装成的数据结构(集合)
- 前端面试题(转)
- iOS推送 再备