您的位置:首页 > 其它

LintCode:Ugly Number

2016-04-25 20:49 381 查看
LintCode:Ugly Number

class Solution:
# @param {int} num an integer
# @return {boolean} true if num is an ugly number or false
def isUgly(self, num):
# Write your code here
if num == 0:
return False
while num != 2 or num != 3 or num != 5:
if num % 2 == 0:
num /= 2
elif num % 3 == 0:
num /= 3
elif num %5 == 0:
num /= 5
else:
break
if num == 1:
return True
return False
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: