Ugly numbers
2015-09-15 21:56
323 查看
Write a program to check whether a given number is an ugly number.
Ugly numbers are positive numbers whose prime factors only include
Note that
Ugly numbers are positive numbers whose prime factors only include
2, 3, 5. For example,
6, 8are ugly while
14is not ugly since it includes another prime factor
7.
Note that
1is typically treated as an ugly number.
class Solution(object): def isUgly(self, num): """ :type num: int :rtype: bool """ if num<1: return False ugly = [2,3,5] for i in ugly: while num % i==0: num /= i return num==1
相关文章推荐
- STUN\TURN\ICE在互联网视频p2p通信中的应用
- 要考试了!
- mysql创建索引
- 垂直型爬虫架构设计(2)
- 第102讲:通过案例解析Akka中的Actor运行机制以及Actor的生命周期学习笔记
- 自绘菜单的实现 ----------原作者querw
- P2P爬虫-拍拍贷
- Objective-C 基础知识之(九):创建对象的方法
- SVN从服务器update时报错,提示Working copy和文件被锁的解决方法
- hdu 5446(中国剩余+lucas+按位乘)
- 第三课 基本绘图命令
- CoreAnimation 核心动画 简称CA
- hdu 5446(中国剩余+lucas+按位乘)
- 华为OJ题5---图片整理
- 从零实现来理解机器学习算法:书籍推荐及障碍的克服
- ActionBarSherlock SlidingMenu整合,解决SlidingMenu example的getSupportActionBar()方法不能用问题
- 食物库App Android客户端主界面的实现
- SSLOJ2201 树
- 关于Adaboost强分类器的训练
- 关于Adaboost强分类器的训练