leetcode-easy-math-326. Power of Three
2024-09-02 11:55:44
mycode
class Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
while n > 2:
if n%3 != 0 :
return False
n = n // 3
print(n)
return n == 1
参考
class Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
if n <= 0:
return False
while n%3 == 0:
n = n/3
return n==1
最新文章
- Entity Framework 6 Recipes 2nd Edition(9-3)译->;找出Web API中发生了什么变化
- 微软云Azure Website 远程调试
- Laravel 5.1 文档攻略 —— Eloquent Collection
- 组合数问题hdu5894
- 如何把项目托管到GitHub
- Redis 3.0 集群搭建
- Leetcode 225 Implement Stack using Queues
- 1015. Reversible Primes (20)
- Mysql 配置主从服务自动同步功能
- php之面向对象(2)
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(29)-T4模版
- C++ tree(1)
- linux常用命令(CentOS)
- springaop——AspectJ不可不知的细节
- Python异常处理详解
- 【Java每日一题】20170216
- Android 闪烁动画
- Bootstrap知识记录:排版样式
- [js]this关键字代表当前执行的主体
- 八(第三篇)、主体结构元素——time元素、pubdate属性